Reducing 6 character string into 2 character string

--- So here's part 2 of my problem / This is the follow-up to my previous question ---
--- part 1 of this question is "merging characters into one cell, keeping the order" ---
How can I reduce a 6 character string into the right 2 character string ?
guidelines :
- the 6 character string is made up of up to 3 different characters, being A B C
- all 6 character strings list As first, Bs second and Cs third
- if the 6 character string contains 4 or more of the same characters, it should be reduced into a 2 character string of 2 times that same character
e.g. AAAABC --> AA
- if the 6 character string is AABBCC, then it should be reduced to the 'exception-string' NO
e.g. AABBCC --> NO
- if the 6 character string contains exactly 3 of the same characters, it should be reduced into a 2 character string of the 2 characters that occur most
e.g. ABBBCC --> BC
How do I fit this into just one formula ?
Thanks !

"I was actually thinking about something like :
if ?????? = AABBCC, then NO,
else : if ?????? contains A, B and C,..."
I thought about that awhile and investigated a few dead ends before thinking 'Wait a minute...there are only 28 possible 6 character strings.'
With that low number, the simplest solution is to list them in one column, list the two character result beside each one, then use that as a Lookup Table:
Same table as before.
Column L uses my version of Yvan's formula to produce the string from the entries in columns A,B and C
Column Q uses the string in L as the search key for VLOOKUP to find and return the two character string shown.
Q2: =VLOOKUP(L,Table 2 :: A:B,2,FALSE)
"FALSE" sets the formula to look for an exact-match. Probably unnecessary here, as all possible matches are in Table 2. Here is the top part of that table:
For convenience, here's the full data list for Table 2. Copy and Paste into a new table for your own use.
6 char
2 char
AAAAAA
AA
AAAAAB
AA
AAAAAC
AA
AAAABB
AA
AAAABC
AA
AAAACC
AA
AAABBB
AB
AAABBC
AB
AAABCC
AC
AAACCC
AC
AABBBB
BB
AABBBC
AB
AABBCC
NO
AABCCC
AC
AACCCC
CC
ABBBBB
BB
ABBBBC
BB
ABBBCC
BC
ABBCCC
BC
ABCCCC
CC
ACCCCC
CC
BBBBBB
BB
BBBBBC
BB
BBBBCC
BB
BBBCCC
BC
BBCCCC
CC
BCCCCC
CC
CCCCCC
CC
Regards,
Barry

Similar Messages

  • How can I Convert a numeric string to a formatted string?

    I have a string value returned from a background tool that will range from 0 to possibly terabytes as a full number.  I want to format that number to use commas and to reduce the character count using an appropriate size modifier (KiB, MiB, GiB, etc).  I've tried converting the string number to a Double value using Double.parseDouble() and then performing the math based on the size of the value with this code:
    Double dblConversionSize;
    String stCinvertedSize;
    dblConversionSize = Double.parseDouble(theValue);
    if (dblConversionSize > (1024 * 1024 * 1024))
         stConvertedSize = String.format("%,.000d", dblConversionSize / 1024 / 1024 / 1024) + " TiB";
    I've also tried using
         String.valueOf(dblConversionSize / 1024 / 1024 / 1024) + " TiB";
    However, the formatting is failing and I'm either getting a format exception or the result is displayed as a number with no decimal component.
    Anyone have a recipe for this?
    Thanks,
    Tim

    TOLIS Tim wrote:
    Thanks, but the reason for using Double is that the division math can leave me with values like 2.341 GiB.  I don't want to drop the values (or round) on the right side of the decimal point.
    Then you may look for DigDecimal which avoids digitization errors.
    NumberFormat will handle all subclasses of Number. You might need another specialization. Just look at the API which one is suitable.
    bye
    TPD

  • My new wirelss keyboard is repeating the "\" character endlessly; also inserting them into the string of characters I'm typing.  It does is in word and in both safari and firefox.  How do I get this to stop?

    My new wireless keyboard is repeating the "\" character endlessly.  It also inserts the '\" into strings of characters as I type them in word or safari or firefox.  I can't erase the characters fast enough or type fast enough not to get these characters.  \Help!

    Try changing the batteries on the keyboard or see if the keyboard has some sort of reset available.

  • How to read a string character by character and pass it into an array

    Hi,
    I have a requirement to write a function.The thing is,i need to read string,replace space with a NULL,return in the form of an arrayy.
    for this what i thought is,if the character is not a space,i need to put that into array,if its space,put a NULL for that.
    the string is of type varchar2.
    ex:XX XX XX
    i need some suggestions for this.
    thanks

    Well, you can just use a loop that runs for the length of the string.
    Then for each iteration of the loop, take the next character of the string (substr or similar) and add it to the array. If it's a space, then add a NULL to the array (if that's what you want).
    Easy :)

  • How to convert strings into character type?

    I have created a function module which will display the attributes of the fields of the structure/table by using "DESCRIBE FIELD" command. The problem is that it supports only character-type data objects and the program goes into dump
    if the structure contain any string type.

    Please have a look at class CL_ABAP_DATADESCR. Using this instances of this class should provide all information needed...
    Reward points, if reply is applicable

  • How to convert character string into ascii format correctly

    dear all
    I'm using encryption technique in my application(oracle formas 6i). character stream convert to the ascii format and add some numeric value and again convert to the character format
    >>>>
    here I'm using ASCII and CHR functions.
    >>>>
    .net program also using same algorithm to encrypt this password.....finally both the character strings are not equel.(This happens if the character string's ascii value greater than 127. otherwise both are equel).
    pls give me a solution for this
    thanks and regards
    buddhike

    hir dear
    do u want to encrypt & dcrypt your password.which version of oracle you are using
    first store these procedure in Oracle Databases: dbms_obfuscation_toolkit, dbms_crypto, Transparent Data Encryption
    now u can use these procedure to encrypt & dcrypt your password
    if you any query about those procedures you can ask me
    best regard
    amk

  • Converting a character string to into a date raise ORA-01843

    I always confused in using to_date() function,such as the following example.How could I convert the string "'8-十月-2006 " into a date correctly.Thank you in advance.
    SQL> select TO_DATE('18-十月-2006 16:49:57','dd-mon-yyyy hh24:mi:ss','nls_DATE_language=''SIMPLIFIED CHINESE''') from dual;
    select TO_DATE('18-十月-2006 16:49:57','dd-mon-yyyy hh24:mi:ss','nls_DATE_language=''SIMPLIFIED CHINESE''') from dual
    ORA-01843: not a valid month

    Hello:
    I suppose you have a bad Oracle-client enviroment. If you note, you can't see a valid month, in place you are seeeing tho characters: '??'. This often indicates that you Oracle client settings (like NLS_LANG, NLS_DATE, etc.) are bad and you are not cappable to do some translation to see it.
    Try if you can see another data from your database in Chinesse format, because also is possible that enviroment of your Oracle server is badly configured (like lang variables).

  • Split string into an array (Skip first character)

    I have a string like:
    ,open,close,open
    I want to parse the data into an array (without the first ','). I found and tweaked the following code, but the result was:
    +<blank line> (think this is coming from the first ',')+
    off
    on
    off
    FUNCTION SPLIT (p_in_string VARCHAR2, p_delim VARCHAR2) RETURN t_array
    IS
    i number :=0;
    pos number :=0;
    lv_str varchar2(50) := p_in_string;
    strings t_array;
    BEGIN
    -- determine first chuck of string
    pos := instr(lv_str,p_delim,1,1);
    -- while there are chunks left, loop
    WHILE ( pos != 0) LOOP
    -- increment counter
    i := i + 1;
    -- create array element for chuck of string
    strings(i) := substr(lv_str,1,pos-1);
    -- remove chunk from string
    lv_str := substr(lv_str,pos+1,length(lv_str));
    -- determine next chunk
    pos := instr(lv_str,p_delim,1,1);
    -- no last chunk, add to array
    IF pos = 0 THEN
    strings(i+1) := lv_str;
    END IF;
    END LOOP;
    -- return array
    RETURN strings;
    END SPLIT;
    I am working on a 9i database.

    How is your collection defined? Assuming you are doing something like
    SQL> create type t_array as table of varchar2(100);
      2  /
    Type created.then you would just need to add an LTRIM to the code that initializes LV_STR and add appropriate EXTEND calls when you want to extend the nested table
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace FUNCTION SPLIT (p_in_string VARCHAR2, p_delim VARCHAR2)
      2    RETURN t_array
      3  IS
      4    i number :=0;
      5    pos number :=0;
      6    lv_str varchar2(50) := ltrim(p_in_string,p_delim);
      7    strings t_array := t_array();
      8  BEGIN
      9    -- determine first chuck of string
    10    pos := instr(lv_str,p_delim,1,1);
    11    -- while there are chunks left, loop
    12    WHILE ( pos != 0)
    13    LOOP
    14      -- increment counter
    15      i := i + 1;
    16      -- create array element for chuck of string
    17      strings.extend;
    18      strings(i) := substr(lv_str,1,pos-1);
    19      -- remove chunk from string
    20      lv_str := substr(lv_str,pos+1,length(lv_str));
    21      -- determine next chunk
    22      pos := instr(lv_str,p_delim,1,1);
    23      -- no last chunk, add to array
    24      IF pos = 0
    25      THEN
    26        strings.extend;
    27        strings(i+1) := lv_str;
    28      END IF;
    29    END LOOP;
    30    -- return array
    31    RETURN strings;
    32* END SPLIT;
    SQL> /
    Function created.
    SQL> select split( ',a,b,c', ',' ) from dual;
    SPLIT(',A,B,C',',')
    T_ARRAY('a', 'b', 'c')If T_ARRAY is defined as an associative array, you wouldn't need to have the EXTEND calls but then you couldn't call the function from SQL.
    Justin

  • Spliting a 16 character string into 4

    Hi All,
    I'm new to Java and I'm a bit stumped on how i can separate this string:
    String x = 1000 11000 1000 0000
    by 4, like 1000
    1100
    1000
    0000
    I tried using the tokenizer and split functions but I couldn't figure it out.
    String [] sub = w.split("\4");
    for(int i=0; i<sub.length; i++){
    System.out.println(sub);
    Any help or advice is greatly appreciated.
    Thx

    As the numbers are space seperated, try
    String[] strings = w.split(" ");
    Peter,
    Since the title indicates that the base string has 16 characters I assumed that there was no group separator so split() was not applicable. I also assumed that the spaces shown in the example were artificial and being used to illustrate the groups.
    If my assumptions are wrong then your use of split() is by far the best solution. If my assumptions are right then I think substring() is the way to go.
    We will only resolve the issue if the OP bothers to respond!
    Sabre

  • How to insert the '&' character into table which is between in a string

    SQL> create table s(ss varchar(10));
    Table created.
    SQL> insert into s values('2 & 3');
    Enter value for 3:
    old 1: insert into s values('2 & 3')
    new 1: insert into s values('2 ')
    1 row created.
    SQL> select * from s;
    SS
    2
    SQL> drop table s;
    Table dropped.
    SQL> create table s(ss varchar2(10));
    Table created.
    SQL> insert into s values('2 & 3');
    Enter value for 3:
    old 1: insert into s values('2 & 3')
    new 1: insert into s values('2 ')
    1 row created.
    SQL> select * from s;
    SS
    2
    SQL> drop table s;
    Table dropped.
    SQL> create table s(ss nvarchar2(10));
    Table created.
    SQL> insert into s values('2 & 3');
    Enter value for 3:
    old 1: insert into s values('2 & 3')
    new 1: insert into s values('2 ')
    1 row created.
    SQL> select * from s;
    SS
    2
    SQL> drop table s;
    Table dropped.
    SQL> create table s(ss char(10));
    Table created.
    SQL> insert into s values('2 & 3');
    Enter value for 3:
    old 1: insert into s values('2 & 3')
    new 1: insert into s values('2 ')
    1 row created.
    SQL> select * from s;
    SS
    2
    SQL> drop table s;
    Table dropped.
    SQL> create table s(ss nchar(10));
    Table created.
    SQL> insert into s values('2 & 3');
    Enter value for 3:
    old 1: insert into s values('2 & 3')
    new 1: insert into s values('2 ')
    1 row created.
    SQL> select * from s;
    SS
    2
    Edited by: user10438587 on 06-Jan-2009 07:57

    Here is one way ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.41
    satyaki>
    satyaki>
    satyaki>select '2 '||chr(38)||' 3' res from dual;
    RES
    2 & 3
    Elapsed: 00:00:00.20
    satyaki>Regards.
    Satyaki De.

  • How to put quote character into string on CSS11500?

    I'm trying to write kal script. Our service returns response in this form:
    status="0" version 1.0
    or
    status="1" version 1.0
    I'm able to connect to, but I need to write
    somethink like
    socket waitfor ${SOCKET} "status="1""
    But it causes syntax error. I tried \"1\", \'1\', ""1"", but nothing works.
    Does anyone have idea how to write this?

    you could also provide hexadecimal value instead of text using the option 'raw' at the end of the socket command.
    http://www.cisco.com/en/US/products/hw/contnetw/ps792/products_administration_guide_chapter09186a00801eea3e.html#1004389
    Regards,
    Gilles.

  • Oracle View export/import copy

    good morning all,
    i have a vpn connection to an oracle database am connecting via oracle client 10g OS is windows.. now i have view with 12 fields now when i query the view the results comes in 12 seperate lines..
    field1
    field2
    field
    field
    field
    field
    field
    field
    out put of field 1
    field1
    field2
    field
    field
    field
    field
    field
    field
    output of field 2
    and so on till field 12
    i want to know how can this be in just one line ..
    am giving the query
    select * from <viewname> where rownum < 5
    and i have half million records in this view what is the best way to export this view or to save the view as HTML or in some other file.. i dont have permission to use enterprise manager
    thanks in advance

    If the column data is too long then it can't come in one line, if the data string is short (lets say 3-6 chars) then you can try to reduce the column length to fix it in one page. But if you want to make it permanent then you need to modify the columns and reduce the character length. But this could be a problem if the future data will have more characters.
    What I suggest is to retrieve the required columns

  • Can't print from my Apple Laserwriter 16/600 PS

    Hello,
    I have an Apple Laserwriter 16/600 PS that I used to be able to print documents to from my Mac G4 OS 10.2.8 via a network connection with my Mac 9600/OS 8 as a shared printer. It was an easy solution to the cabling issues between laserwriters of that vintage and G4s and USB ports. But this was not a good option after I upgraded my G4 to OS 10.4.8.
    So now I have connected this printer to my G4/OS 10.4.8 using a Keyspan USB parallel printer adapter. I am networked using built-in Ethernet; connect to my ISP via TCP/IP using DHCP that automatically assigns an IP address to my computer and router. I have AppleTalk set to active and configured automatically. I do notice that I have no AppleTalk zones that I can use. So I'm not sure what use this is.
    I set up the printer on my G4 with the Printer Setup Utility using Line Printer Daemon - LPD protocol. I used the same IP address as my computer, gave it a name and location and selected the model Apple Laserwriter 16/600 PS v2014.106 to print from the menu list in the utility.
    I can see the printer using Apple System Profiler under Hardware/Printers/Queue Name. I can see the printer in my applications' page setup dialog. But I cannot print anything. (At one point during my hours of effort, and with another setup configuration, when I viewed the job printing from the setup utility, it said the job was printing, but it just ran and ran. Now it simply says "no job printing.")
    I repaired permissions, used MacJanitor and restarted everything. Still no luck. The cable is plugged in properly as far as I can tell.
    Questions:
    1. Have I assigned the incorrect IP address to the printer (it is the same as my ISP assigned IP address for my computer? If so what should I assign as an IP address?
    2. Do I need to download an Apple Laserwriter 16/600 print driver or some other software to make the computer and printer agree with each other?
    3. Should I be using another protocol in the Printer Setup Utility? IPP and HP Jet Direct - Socket are the other protocols available in this utility. Once again, what is the correct IP address to use for a connected printer?
    4. Why are there no AppleTalk zones available even though I have made AppleTalk active?
    5. I do have access to OS Classic and the old printer utility, but how do I utilize that to make this printer work on OS 10.4.8?
    I am sure there must be a solution and I have spent a long time Googling and searching. If someone could walk me through a solution or point to an article or download that would help, I would be so appreciative.
    Thanks for any help on this.
    Shelley
    Power PC G4 Mac OS X (10.4.8)
    Message was edited by: Shelley Schreiber

    Shelley,
    The adapter is just that. It changes one plug at one end to a standard RJ 45 phone style socket on the other end. Plug in the <---> plug into the <---> socket on the back of the printer. The box end of the transceiver has a standard socket for the usual phone style plug.
    "Do the transceiver (that I am assuming has the aaui adapter plug on it) and the RJ45 ethernet plug come as separate items that I then string together with the cat 5 cable? "
    They can come as a box with two sockets and one short adapter cable or a box with one RJ 45 socket and one short cable permenantly attached that has the <---> plug for the printer.
    "Or are these three items available as a unit that I can just order, ready to go (i.e. plug into the printer and connect to the computer.)?"
    I have not seen one that was long enough to eliminate the need for the cat 5 ethernet cable. The length of cable needed varies so widely that manufacturers just make the adapter, you choose the length of cable.
    Ethernet does not split like phone splitters. Hubs were designed for that task. Your router acts as a spliter/hub PLUS routing duties so go ahead and use it for its intended purpose. The uplink port on the router goes to the link with another network so save that port for your DSL modem.
    Wikipedia offers a little background reading here:
    http://en.wikipedia.org/wiki/Router
    http://en.wikipedia.org/wiki/Network_switch
    Not to be outdone, Yahoo has a site:
    http://answers.yahoo.com/question/index?qid=20070331094643AAcs2Rs
    So, to recap, you do not need a separate ethernet hub - good guess, they do exist. A switch is a fast HUB - oversimplified explanation - and is not needed in your situation. Your router has a hub plus an uplink port for linking to another router connected to another Local Area Network.
    Think of a router this way. My son has LAN parties with ten or more computers in one room connected to the internet. Without a router, the internet company would see ten computers and send him a bill for ten internet connections. At AOL rates, that would be $220 or more a month. Ouch! A router takes those ten computers and reduces the network signals into one so he only gets a bill for one $22/month connection. Much nicer for a student's budget.
    Hope this helps.
    Jim

  • Nokia 1020 Auto MMS

    I have a Nokia 1020 on 3 (three.co.uk).
    If I use characters that have accents e.g. ô or â (when I use them for typing in Welsh) the SMS changes to MMS automatically, and a long SMS may change into 2 MMS messages which I have to pay for under my contract
    (I've onlyu just noticed and not sure how much this is costing me!)
    I've uploaded a screenshot showing the character count at the bottom of the text message.
    Solved!
    Go to Solution.
    Attachments:
    wp_ss_20131203_0002 (2).jpg ‏81 KB

    Not a real solution but you could always change to reduced SMS character set in Settings > network+:
    print screen windows
    Happy to have helped forum in a small way with a Support Ratio = 37.0

  • Array of movieclips

    I have an array with the instance names of 150+ movieclips
    that i would like to set the ._visible property to true/false. How
    can i do this??? i thought this would work. Am I way off???
    for (var i:Number = 0; i < aAllCircles.length; i++){
    var myMC:MovieClip;
    myMC = aAllCircles i ; i IS IN SQUARE BRACKETS OF COURSE
    myMC._visible=false;
    thanks in advance.

    BCA_9,
    > I have an array with the instance names of 150+
    movieclips
    > that i would like to set the ._visible property to
    true/false.
    > How can i do this??? i thought this would work. Am I way
    > off???
    You're way off.
    > for (var i:Number = 0; i < aAllCircles.length; i++){
    This is your for() statement. So far, so good. aAllCircles
    is
    presumably your array. The Array class specifies an
    Array.length property,
    so that's fine.
    > var myMC:MovieClip;
    Here, you're declaring an undefined MovieClip reference.
    Still fine --
    though I doubt you'd really want to declare this variable
    anew all 150+
    times, right? You could declare this outside the loop.
    > myMC = aAllCircles;
    Now you're trying to set that variable, myMC, to the Array
    instance.
    But myMC is supposed to be a MovieClip! If aAllCircles
    contains references
    to movie clips (not just strings, which happen to reflect the
    intance names
    of your movie clips, then you should use your counter
    variable, i, to access
    the relevant index of the array.
    The web version of these forums usually has trouble with
    references to
    brackets and i (and other letters that happen to be HTML
    elements) ... maybe
    that part of your code got truncated, here. If so, I may not
    be seeing what
    you actually type. In any case, I'll use n as a counter and
    show you what
    should actually be happening here.
    var myMC:MovieClip;
    for (var n:Number = 0; n < aAllCircles.length; n++) {
    myMC = aAllCircles[n];
    myMC._visible = false;
    Let me stress again, this only works if the elements in your
    array are
    actual movie clip references. I have a hunch that what your
    array actuall
    holds is a bunch of strings. If so, you'll need to use the
    eval() function
    or array access operator to translate those strings into
    actualy references.
    First, let's reduce the above lines into an even more
    compact form. No
    need for the myMC variable at all, as it turns out.
    for (var n:Number = 0; n < aAllCircles.length; n++) {
    aAllCircles[n]._visible = false;
    Now, if your array actuall has strings, you need to do this
    for (var n:Number = 0; n < aAllCircles.length; n++) {
    this[aAllCircles[n]]._visible = false;
    ... because the result of any number in that aAllCircles
    array -- e.g.
    aAllCircles[0] -- will return a string (if the array contains
    strings). I
    don't mean to pound this into the ground, but it happens
    quite a bit in this
    forum. The this[string here] business converts the string
    into a property
    reference of its parent. The global property "this" refers to
    whatever
    object or timeline it's in, so in this case, it refers to the
    timeline these
    movie clip presumably belong to.
    David
    stiller (at) quip (dot) net
    Dev essays:
    http://www.quip.net/blog/
    "Luck is the residue of good design."

Maybe you are looking for

  • How do i upgrade icloud storage

    What do I have to do to upgrade storage for icloud??

  • How do I display or hide a Java menu based on current url in a php page

    How do I display or hide a Javascript menu based on the current url in a php page? I want to specify when a java menu appears on a page based on the current url - does anyone have a script for the vars and conditional statements to make this happen -

  • Mini Sound Output

    I have a Mac Mini and I have hooked up the sound output to my JVC Home Theatre systems so I can play iTunes through it. The problem is that the sound level is very low even with all the outputs turned up to max. I need to have the JVC up to near max

  • Erros in Agent Inbox Profiles for Account Factsheet

    Hello All, I need my service request and service orders to appear in the account fact sheet in the interaction center role For the missing customization I go to CRM-Interaction Center WebClient-Agent Inbox-Define Inbox Profiles where I have created a

  • How to create a DBlink from oracle database on unix to sqlserver

    Hi I need to create a database link from oracle database on solaris machine to sqlserver database.I found that the database link cannot be created from oracledatabase 10g to microsoft sqlserver.So i am planning to go for another windows server where