Search Results

Search found 10 results on 1 pages for 'aab'.

Page 1/1 | 1 

  • Function in c++ for finding if a word is prefix

    - by VaioIsBorn
    Let say i have some words AB, AAB, AA. AB is not a prefix to AAB but AA is a prefix to AAB because if i just add B at the end of AA it will become AAB, which is not possible with AB. So, is there any function in c++ (STL) so that i can determine of two words if one is prefix to the another ? Thanks.

    Read the article

  • PL/SQL to delete invalid data from token Strings

    - by Jie Chen
    Previous article describes how to delete the duplicated values from token string in bulk mode. This one extends it and shows the way to delete invalid data. Scenario Support we have page_two and manufacturers tables in database and the table DDL is: SQL> desc page_two; Name NULL? TYPE ----------------------------------------- -------- ------------------------ MULTILIST04 VARCHAR2(765) SQL> SQL> desc manufacturers; Name NULL? TYPE ----------------------------------------- -------- ------ ID NOT NULL NUMBER NAME VARCHAR In table page_two, column multilist04 stores a token string splitted with common. Each token represent a valid ID in manufacturers table. My expectation is to delete invalid token strings from page_two.multilist04, which have no mapping id in manufacturers.id. For example in below SQL result: ,6295728,33,6295729,6295730,6295731,22, , value 33 and 22 are invalid data because there is no ID equals to 33 or 22 in manufacturers table. So I need to delete 33 and 22. SQL> col rowid format a20; SQL> col multilist04 format a50; SQL> select rowid, multilist04 from page_two; ROWID MULTILIST04 -------------------- -------------------------------------------------- AAB+UrADfAAAAhUAAI ,6295728,6295729,6295730,6295731, AAB+UrADfAAAAhUAAJ ,1111,6295728,6295729,6295730,6295731, AAB+UrADfAAAAhUAAK ,6295728,111,6295729,6295730,6295731, AAB+UrADfAAAAhUAAL ,6295728,6295729,6295730,6295731,22, AAB+UrADfAAAAhUAAM ,6295728,33,6295729,6295730,6295731,22, SQL> select id, encode_name from manufacturers where id in (1111,11,22,33); No rows selected SQL> Solution As there is no existing SPLIT function or related in PL/SQL, I should program it by myself. I code Split intermediate function which is used to get the token value between current splitter and next splitter. Next program is main entry point, it get each column value from page_two.multilist04, process each row based on cursor. When it get each multilist04 value, it uses above Split function to get each token string stored to singValue variant, then check if it exists in manufacturers.id. If not found, set fixFlag to 1, pending to be deleted.

    Read the article

  • Bash and regex problem : check for tokens entered into a Coke vending machine

    - by Michael Mao
    Hi all: Here is a "challenge question" I've got from Linux system programming lecture. Any of the following strings will give you a Coke if you kick: L = { aaaa, aab, aba, baa, bb, aaaa"a", aaaa"b", aab"a", … ab"b"a, ba"b"a, ab"bbbbbb"a, ... } The letters shown in wrapped double quotes indicate coins that would have fallen through (but those strings are still part of the language in this example). Exercise (a bit hard) show this is the language of a regular expression And this is what I've got so far : #!/usr/bin/bash echo "A bottle of Coke costs you 40 cents" echo -e "Please enter tokens (a = 10 cents, b = 20 cents) in a sequence like 'abba' :\c" read tokens #if [ $tokens = aaaa ]||[ $tokens = aab ]||[ $tokens = bb ] #then # echo "Good! now a coke is yours!" #else echo "Thanks for your money, byebye!" if [[ $token =~ 'aaaa|aab|bb' ]] then echo "Good! now a coke is yours!" else echo "Thanks for your money, byebye!" fi Sadly it doesn't work... always outputs "Thanks for your money, byebye!" I believe something is wrong with syntax... We didn't provided with any good reference book and the only instruction from the professor was to consult "anything you find useful online" and "research the problem yourself" :( I know how could I do it in any programming language such as Java, but get it done with bash script + regex seems not "a bit hard" but in fact "too hard" for anyone with little knowledge on something advanced as "lookahead"(is this the terminology ?) I don't know if there is a way to express the following concept in the language of regex: Valid entry would consist of exactly one of the three components : aaaa, aab and bb, regardless of order, followed by an arbitrary sequence of a or b's So this is what is should be like : (a{4}Ua{2}bUb{2})(aUb)* where the content in first braces is order irrelevant. Thanks a lot in advance for any hints and/or tips :)

    Read the article

  • Having trouble with match wildcards in array

    - by Senthil
    I've a master text file and exceptions file and I want to match all the words in exception file with master file and increase counter, but the trick is with wildcards. I'm able to do without wildcards with this: words = %w(aaa aab acc ccc AAA) stop = %q(/aa./) words.each do |x| if x.match(/aa./) puts "yes for #{x}" else puts "no for #{x}" end end = yes for aaa yes for aab no for acc no for ccc yes for AAA Also which would be the best way to go about this, using arrays or some other way. Edit: Sorry for the confusion. Yes stop has multiple wildcards and I want to match all words based on those wildcards. words = %w(aaa aab acc ccc AAA) stop = %q(aa* ac* ab*) Thanks

    Read the article

  • Java reference storage question

    - by aab
    In java, when you pass an object to a method as a parameter, it is actually passing a reference, or a pointer, to that object because objects in Java are references. Inside the function, it has a pointer to that object which is a location in memory. I am wondering where this pointer lives in memory? Is a new memory location created once inside the function to hold this reference?

    Read the article

  • python: creating a list inside a dictionary

    - by user1871081
    I just started using python and I'm trying to create a program that will read a file that looks like this: AAA x 111 AAB x 111 AAA x 112 AAC x 123 ... the file is 50 lines long and I'm trying to make the letters into keys in a dictionary and the numbers lists that correspond with the keys. I want the output to look like this: {AAA: ['111', '112'], AAB: ['111'], AAC: [123], ...} This is what I've tried file = open("filename.txt", "r") readline = file.readline().rstrip() while readline!= "": list = [] list = readline.split(" ") j = list.index("x") k = list[0:j] v = list[p + 1:] d = {} if k in d == False d[k] = [] d[k].append(v) else d[k].append(v) readline = file.readline().rstrip() I keep getting syntax errors on my if statement and I can't figure out what I've done wrong.

    Read the article

  • Finding spelling of an element in an ignore case dictionary

    - by Andrew White
    Hi, Weird question, but I have a dictionary created with StringComparer.OrdinalIgnoreCase, looks something like this AaA, 10 aAB, 20 AAC, 12 I then use myDictionary["AAA"] to find the value associated with the key, but what I also need to know is what the actual spelling of the key is in myDictionary, e.g. in this case I want it to return AaA. Any way to do this without a loop? Thx.

    Read the article

  • Context free grammer

    - by Evil
    Hello. I have this problem where i need to convert the following CFG to CFG in CNF. S- ABa A- aab B- Ac I know the steps are as follows. 1) Remove epsilon transitions - Done 2) remove unit productions 3) convert to CNF by: 3.1] introduce a new non terminal for each term 3.2] replace terminals in the productions rules with the new nonterminal 3.3] introduce new nonterminals to reduce the length of the right side of each production i'm a bit confused on how i would do that with the problem above. Mostly i am confused on step 2 and unit productions. If i could get some help or perhaps a link to a good tutorial that would be most helpful.

    Read the article

  • MySQL : incrementing text id in DB

    - by BarsMonster
    I need to have text IDs in my application. For example, we have acceptable charset azAZ09, and allowed range of IDs [aaa] - [cZ9]. First generated id would be aaa, then aab, aac, aad e.t.c. How one can return ID & increment lower bound in transaction-fashion? (provided that there are hundreds of concurrent requests and all should have correct result) To lower the load I guess it's possible to define say 20 separate ranges, and return id from random range - this should reduce contention, but it's not clear how to do single operation in the first place. Also, please note that number of IDs in range might exceed 2^32. Another idea is having ranges of 64-bit integers, and converting integer-char id in software code, where it could be done asyncroniously. Any ideas?

    Read the article

  • Porting Python algorithm to C++ - different solution

    - by cb0
    Hello, I have written a little brute string generation script in python to generate all possible combinations of an alphabet within a given length. It works quite nice, but for the reason I wan't it to be faster I try to port it to C++. The problem is that my C++ Code is creating far too much combination for one word. Heres my example in python: ./test.py gives me aaa aab aac aad aa aba .... while ./test (the c++ programm gives me) aaa aaa aaa aaa aa Here I also get all possible combinations, but I get them twice ore more often. Here is the Code for both programms: #!/usr/bin/env python import sys #Brute String Generator #Start it with ./brutestringer.py 4 6 "abcdefghijklmnopqrstuvwxyz1234567890" "" #will produce all strings with length 4 to 6 and chars from a to z and numbers 0 to 9 def rec(w, p, baseString): for c in "abcd": if (p<w - 1): rec(w, p + 1, baseString + "%c" % c) print baseString for b in range(3,4): rec(b, 0, "") And here the C++ Code #include <iostream> using namespace std; string chars="abcd"; void rec(int w,int b,string p){ unsigned int i; for(i=0;i<chars.size();i++){ if(b < (w-1)){ rec(w, (b+1), p+chars[i]); } cout << p << "\n"; } } int main () { int a=3, b=0; rec (a+1,b, ""); return 0; } Does anybody see my fault ? I don't have much experience with C++. Thanks indeed

    Read the article

1