Help with recursive function to print number patterns

I'm sorry for having to ask for homework help - I'm badly stuck on this! Can someone give me a kick in the right direction with this?
need a recursive function with a single positive int parameter n. the function should write (2^n - 1) integers and should be in the following pattern...
n = 1, Output: 1
n = 2, Output: 1 2 1
n = 3, Output: 1 2 1 3 1 2 1
n = 4, Output: 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
n = 5, Output: 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
function should valid for all positive integer values of n
This was tagged as a 'short' problem...so it shouldnt take too much code...I am hung on on the following:
*Do I keep track of the numbers printed, if so how?  I only have a single parameter to call with so I am confused as to how I could get an entire pattern without keeping track of the history
*I had initially thought it would be necessary to cut it in half and do the 2nd half backwards (ie: for n=3, I would take care of the 1 2 1 - then 3 - then 1 2 1...but even then it seems like I could cut 1 2 1 in half the same way and therefor I should be able to do ALL of it in single parts...
Can someone veer me in the right direction here? I'm really lost with this.

This was tagged as a 'short' problem...so it shouldnt
take too much code...Yeah, the method body could be done in a few lines.
I am hung on on the following:
*Do I keep track of the numbers printed, if so how?Not explicitly. Use the call stack. That is, use the fact that when you're recursing, the previous values of numbers are preserved in the previous method invocation.
I only have a single parameter to call with so I am
confused as to how I could get an entire pattern
without keeping track of the historyYou don't have to store anything across method invocations.
I had initially thought it would be necessary to cut
it in half and do the 2nd half backwards (ie: for
n=3, I would take care of the 1 2 1 - then 3 - then 1
2 1...but even then it seems like I could cut 1 2 1
in half the same way and therefor I should be able to
do ALL of it in single parts...No, it's MUCH simpler than that. It's easier than yo uthink.
Can someone veer me in the right direction here? I'm
really lost with this.Try this simpler version of the problem:
Write a recursive method that creates this output:
n = 1: 1
n = 2: 1 2
n = 3: 1 2 3
And try this simpler version:
n = 1: 1
n = 2: 2 1
n = 3: 3 2 1

Similar Messages

  • Help! Recursive function to print ncr

    hi ,everyone
    i am writing a program to print out the ncr of an array
    ie gievn [1,2,3]
    my outcome is expected to be
    1 2 3
    1 3 2
    2 1 3
    2 3 1
    3 1 2
    3 2 1
    however my program output is
    12 3
    3 2
    2 13
    3 1
    3 1 2
    2 1
    can somebody help me out to make my program to output the expected outcome
    here is the code
    import java.util.*;
    public class ncrq
         public static void main(String args[])
              int[] value=new int[3];
              value[0]=1;
              value[1]=2;
              value[2]=3;
              printNcr(value);
         public static void printNcr(int[] value)
              if(value.length==0)
                   return;
              else
                   int[] outcome=new int[value.length-1];
                   for(int i=0;i<value.length;i++)
                        System.out.print(value[i]+" ");
                        copyArray(value.length,outcome,value,i);
                        printNcr(outcome);
                        System.out.println();
         public static void copyArray(int originalLength,int[] outcome,int[] income,int i)
              int j=0;
              for(int k=0;k<originalLength;k++)
                   if(k!=i)
                   outcome[j++]=income[k];
    }

    I would say to treat each character more like a symbol because that's how we handle such problems. Then write a method that tracks the position of each symbol / object and bumps it to antoher position and it'll do this for each object.
    such as:
    123
    where 1 is obj a, 2 is obj b, and 3 is obj c.
    Then pick on obj b and bump it to obj c's position and print the result, then bump it to obj a's position.
    123 ---> 132 DONE focusing on obj a.
    213 ---> 231 DOND focusing on obj b.
    312 ---> 321 DOND focusing on obj c.
    The number of bumps for each object will be determined by the original objects size, so a 3 digit number would have two bumps for each object and a 4 digit number (1234) would have 3 bumps per obj, etc....
    A key part to this letting each obj stand in as a "leader" and having two bumps after it's assignment. Otherwise you'll recieve duplicate values.
    So you would get (leaders are in bold): 1,2,3 ----> 1,3,2 ----> 2,1,3 -----> 2,3,1 -----> 3,1,2 ---->3,2,1

  • Help with stored function

    Hi...I was wondering if I could get help with this function. How do i write a function to return hours between a begin date and an end date for an employee. Thanks so much

    EdStevens wrote:
    AlexeyDev wrote:
    sb92075 wrote:
    select (date2-date1)*24 from dual;not as above but as below
    select (date2-date1)/24 from dual;date2-date1 is amount of days. Divide it by 24 and what? if you multiply it on 24 you will have a chance to know how many hours between these two dates. :-)Don't forget that a DATE type also includes a time component.I suppose it doesn't matter if you did a difference between two dates. The result is always number of days.

  • Problem with recursive function & Exception in thread "AWT-EventQueue-0"

    I hope that title doesn't put everyone off :)
    I have a recursive function that takes in a list of words, and a reference to my current best board. I am kludging the escape function +(tryWords.size() == 0 || mTotalBlankBlocks < 200)+ atm, but eventually it will escape based on whether the current bestBoard meets certain requirements. The function makes iterates through a list of words, and finds all the spaces that the word would fit into the puzzle: getValidSpacedPositions(currentWord); - it then iterates through each of these; placing a word, removing that word from the iterator and the relevant arrayLists and then recurses the function and tries to do the same with the next word etc.
    private void computeBoards(ArrayList<Word> tryWords, Board bestBoard) {
         if (tryWords.size() == 0 || mTotalBlankBlocks < 200)
              return;
         for(Iterator<Word> iter = tryWords.iterator(); iter.hasNext(); ){
              Word currentWord = new Word();
              currentWord = iter.next();
              ArrayList<Position> positions = new ArrayList<Position>();
              positions = getValidSpacedPositions(currentWord);
              if (positions.size() != 0)
                   iter.remove();
              System.out.println();
              int placedWordsIndex = tryWords.indexOf(currentWord);
              System.out.print(placedWordsIndex+". "+currentWord.getString()+" with "+positions.size()+" positions / ");
              for (Position position : positions) {
                   System.out.println("Pos:"+(positions.indexOf(position)+1)+" of "+positions.size()+"  "+position.getX()+","+position.getY()+","+position.getZ());
                   int blankBlocksLeft = placeWord(currentWord, position);
                   if(blankBlocksLeft != 0)
                        mPlacedWords.add(currentWord);
                        // TODO: Kludge! Fix this.
                        mUnplacedWords.remove(placedWordsIndex+1);
                        System.out.println("adding "+currentWord.getString()+" to added words list");
                        Board compareBoard = new Board(blankBlocksLeft, mPlacedWords.size());
                        if (compareBoard.getPercFilled() > bestBoard.getPercFilled())
                             bestBoard = new Board(blankBlocksLeft, mPlacedWords.size());
                        //**RECURSE**//
                        computeBoards(tryWords, bestBoard);
                        mUnplacedWords.add(currentWord);
                        removeWord(currentWord);
                        System.out.println("removing "+currentWord.getString()+" from added words list");
                   else
                        System.out.println("strange error, spaces are there but word cannot place");
              System.out.println("**FINISHED ITERATING POSITIONS");
         System.out.println("**FINISHED ITERATING TRYWORDS");
    }This all seems to work fine, but I add it in for completeness because I am not sure if I have done this right. The Exception occurs in the placeWord function which is called from the recursive loop, on the line bolded. For some reason the Arraylist Words seems to initialise with size 1 even though it is a null's when I look at it, (hence all the redundant code here) and I can't seem to test for null either, it seems to works fine for a while until the recursive funciton above has to back up a few iterations, then it crashes with the exception below.
         private int placeWord(Word word, Position originPosition) {
              ArrayList<Word> words = new ArrayList<Word>();
              switch (originPosition.getAxis().getCurrInChar()) {
              case 'x':
                   // TODO: This is returning ONE!!!s
                   words = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords();
                   int tempword1 = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords().size();
                   for (int i = 0; i < word.getLength(); i++) {
                        *if (words.get(0) == null)*
                             mBlockCube[originPosition.getX() + i][originPosition.getY()][originPosition.getZ()] = new Block(word, word.getChar(i));
                        else
                             mBlockCube[originPosition.getX() + i][originPosition.getY()][originPosition.getZ()].addWord(word);
                   break;
              case 'y':
                   words = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords();
                   int tempword2 = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords().size();
                   for (int i = 0; i < word.getLength(); i++) {
                        *if (words.get(0) == null)*
                             mBlockCube[originPosition.getX()][originPosition.getY() + i][originPosition.getZ()] = new Block(word, word.getChar(i));
                        else
                             mBlockCube[originPosition.getX()][originPosition.getY() + i][originPosition.getZ()].addWord(word);
                   break;
              case 'z':
                   words = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords();
                   int tempword3 = mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ()].getWords().size();
                   for (int i = 0; i < word.getLength(); i++) {
                        *if (words.get(0) == null)*
                             mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ() + i] = new Block(word, word.getChar(i));
                        else
                             mBlockCube[originPosition.getX()][originPosition.getY()][originPosition.getZ() + i].addWord(word);
                   break;
              mTotalBlankBlocks -= word.getLength();
              word.place(originPosition);
              String wordStr = new String(word.getWord());
              System.out.println("Word Placed: " + wordStr + " on Axis: " + originPosition.getAxis().getCurrInChar() + " at pos: "
                        + originPosition.getX() + "," + originPosition.getY() + "," + originPosition.getZ());
              return mTotalBlankBlocks;
    Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
         at java.util.ArrayList.RangeCheck(Unknown Source)
         at java.util.ArrayList.get(Unknown Source)
         at com.edzillion.crossword.GameCube.placeWord(GameCube.java:189)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:740)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.computeBoards(GameCube.java:763)
         at com.edzillion.crossword.GameCube.generateGameCube2(GameCube.java:667)
         at com.edzillion.crossword.GameCube.<init>(GameCube.java:42)
         at com.edzillion.crossword.Crossword.actionPerformed(Crossword.java:205)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    Any ideas? I've looked up this exception which didn't shed any light...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    ArrayList<Word> words = new ArrayList<Word>();See the API Javadoc for ArrayList: this creates an empty ArrayList.
    if (words.get(0) == null)This tries to read the first element of the (still empty) array list -> throws IndexOutOFBoundsException
    If you want to stick to that logic (I am too lazy to proof-read your whole algorithm, but that should at least unblock you), you should first check whether the list actually contains at least one element:
    if (!words.isEmpty()) {...}

  • Help with zoom function

    I have some mouse commands to scroll a screen horizontally... need some help adding in a zoom feature where moving the mouse up will zoom in, moving out will zoom out.  Here is the code I have so far:
    import mx.transitions.easing.*;
    import mx.transitions.Tween;
    import flash.filters.DropShadowFilter;
    import mx.events.EventDispatcher;
    //constants
    var CENTER_STAGE:Number = Stage.width/2;
    var SCROLL_HIT_AREA_POSITION:Number = Stage.width/2;//distance from edges of screen that should trigger scrolling
    var RIGHT_SCROLL_HIT_AREA:Number = SCROLL_HIT_AREA_POSITION;
    var LEFT_SCROLL_HIT_AREA:Number = Stage.width - SCROLL_HIT_AREA_POSITION;
    var RIGHT_SCROLL_EDGE:Number = 100;//x pos at which front scene should stop scrolling left
    var LEFT_SCROLL_EDGE:Number = -200;//x pos at which front scene should stop scrolling right
    var scrollableArea:Number = RIGHT_SCROLL_EDGE - LEFT_SCROLL_EDGE;//hill1._width - Stage.width;
    //var SCROLL_CENTER_POINT:Number = scrollableArea/2;
    var SCROLL_DECELERATE_POSITION:Number = 75;//how far from the edges of the scene does the scrolling slow down
    var DEFAULT_FRICTION:Number = 1;
    var SPEED:Number = 50;
    //variables
    var friction:Number;
    var distFromEdge:Number;
    //var swfContainer:MovieClip;
    //var localRoot:MovieClip = this;
    //var localParent:MovieClip = this._parent;
    // determine the correct path to the photos
    var dispatchEvent:Function;
    EventDispatcher.initialize(this);
    setBitmapCaching(true);
    this.onEnterFrame = testForScroll;
    // determine whether to scroll or not and by how much, based on mouse position and position of the scene
    function testForScroll():Void{
        var xMouse:Number = this._xmouse;// where is the mouse on the x axis?
        var yMouse:Number = this._ymouse;// where is the mouse on the x axis?
        var mouseOnStage:Boolean = xMouse > 0 && yMouse > 0; //before someone scrolls into the swf stage area, the mousex and mouse y values are 0, 0 so we need to make sure they are positive values or the scene will begin scrolling to the right immediately
        var mouseInScrollArea:Boolean = xMouse > LEFT_SCROLL_HIT_AREA || xMouse < RIGHT_SCROLL_HIT_AREA;//is the mouse close enough to edge of screen to trigger scrolling
        if(mouseOnStage && mouseInScrollArea){//only execute if mouse is over the scroll trigger area   
            var xScrollPos:Number = pintMC.cowMC._x;//x position of the main movieClip
            var xDirection:Number = (xMouse - CENTER_STAGE)/Math.abs(xMouse - CENTER_STAGE);//what direction is the scene moving   
            var nearLeftEdge:Boolean = xScrollPos > (scrollableArea - 100);
            var nearRightEdge:Boolean = xScrollPos < (RIGHT_SCROLL_EDGE + 100);
            if(nearLeftEdge && xDirection == -1){
                distFromEdge = scrollableArea - xScrollPos;
                friction = (scrollableArea - xScrollPos)/SCROLL_DECELERATE_POSITION;
            }else if(nearRightEdge && xDirection == 1){
                distFromEdge = xScrollPos - RIGHT_SCROLL_EDGE;
                friction = distFromEdge/SCROLL_DECELERATE_POSITION;
            }else{
                friction = DEFAULT_FRICTION;
            //determine how far to move the scene
            var acc:Number = (xMouse - CENTER_STAGE) * (1/SPEED) * friction;
            //will next movement make scene scroll past one of it's edges
            var reachedEdge:Boolean = (xScrollPos - acc) < RIGHT_SCROLL_EDGE || (xScrollPos - acc) > LeftScrollEdge;
            if(!reachedEdge){// only scroll if not going to pass edge
                scrollScene(acc);
    // move the various scenes at relative speeds
    function scrollScene(acc:Number){
        pintMC.cowMC._x -= acc;
        pintMC.flutterbyMC._x -= acc;
        pintMC.grassMC._x -= acc;
        pintMC.cloudMC._x -= (acc/2);
        pintMC.barnMC._x -= (acc/3);
        pintMC.bgMC._x -= (acc/5);
    // in order to optimize performance, we create a bitmap of each moving scene. This eliminates the enormous number of vector redraws Flash must perform if vectors are intersecting.
    function setBitmapCaching(cache:Boolean):Void{
        pintMC.cowMC.cacheAsBitmap = cache;
        pintMC.flutterbyMC.cacheAsBitmap = cache;
        pintMC.grassMC.cacheAsBitmap = cache;
        pintMC.cloudMC.cacheAsBitmap = cache;
        pintMC.barnMC.cacheAsBitmap = cache;
        pintMC.bgMC.cacheAsBitmap = cache;
    Thanks for any help

    You mac doesn't support those preferences.  It only supports tap, double-tap, drag and scrolling.

  • Help with ASO function

    Hi all,
    I need some help with ASO mdx function.
    Avg({Leaves([Employees].Currentmember)}, [Calculated_Field]). This will give me the average for Calculated_Field for all levels of Employees. But i want to add more dimensions like Region and year.
    Please advice how can I achieve this.
    Thanks
    Andy

    you have to use cross join in order to add more dimension members to the formula.This will give you some idea
    Re: Writing formula in Outline??????
    Regards,
    RSG

  • Help with Elements 12 and Print Studio

    i have Elements 12 and cant get print studio supplied with my canon pixma pro 100 to install
    can any one help ??

    You messaged me (but please reply to the forum as it will help others with the same problem):
    "print studio just keeps saying its not compatible with elements 12 or vice versa??".
    Go to Canon's web site and download the latest verson and see if that works. It installed for me OK (not that it worked, as I don't have a compatible printer).
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • I need help with Analytic Function

    Hi,
    I have this little problem that I need help with.
    My datafile has thousands of records that look like...
    Client_Id Region Countries
    [1] [1] [USA, Canada]
    [1] [2] [Australia, France, Germany]
    [1] [3] [China, India, Korea]
    [1] [4] [Brazil, Mexico]
    [8] [1] [USA, Canada]
    [9] [1] [USA, Canada]
    [9] [4] [Argentina, Brazil]
    [13] [1] [USA, Canada]
    [15] [1] [USA]
    [15] [4] [Argentina, Brazil]
    etc
    My task is is to create a report with 2 columns - Client_Id and Countries, to look something like...
    Client_Id Countries
    [1] [USA, Canada, Australia, France, Germany, China, India, Korea, Brazil, Mexico]
    [8] [USA, Canada]
    [9] [USA, Canada, Argentina, Brazil]
    [13] [USA, Canada]
    [15] [USA, Argentina, Brazil]
    etc.
    How can I achieve this using Analytic Function(s)?
    Thanks.
    BDF

    Hi,
    That's called String Aggregation , and the following site shows many ways to do it:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    Which one should you use? That depends on which version of Oracle you're using, and your exact requirements.
    For example, is order importatn? You said the results shoudl include:
    CLIENT_ID  COUNTRIES
    1        USA, Canada, Australia, France, Germany, China, India, Korea, Brazil, Mexicobut would you be equally happy with
    CLIENT_ID  COUNTRIES
    1        Australia, France, Germany, China, India, Korea, Brazil, Mexico, USA, Canadaor
    CLIENT_ID  COUNTRIES
    1        Australia, France, Germany, USA, Canada, Brazil, Mexico, China, India, Korea?
    Mwalimu wrote:
    ... How can I achieve this using Analytic Function(s)?The best solution may not involve analytic functions at all. Is that okay?
    If you'd like help, post your best attempt, a little sample data (CREATE TABLE and INSERT statements), the results you want from that data, and an explanation of how you get those results from that data.
    Always say which version of Oracle you're using.
    Edited by: Frank Kulash on Aug 29, 2011 3:05 PM

  • Help with Sort function in Terminal

    Hello all... this is my first post on here as I'm having some trouble with some Termianl commands. I'm trying to learn Terminal at the moment as it is but I would appreciate some help with this one....
    I'm trying to sort a rather large txt file into alphabetical order and also delete any duplicates. I've been using the following command in Terminal:
    sort -u words.txt > words1.txt
    but after a while I get the following error
    sort: string comparison failed: Illegal byte sequence
    sort: Set LC_ALL='C' to work around the problem.
    sort: The strings compared were `ariadnetr\345dens\r' and `ariadnetr\345ds\r'.
    What should my initial command be? What is Set LC_ALL='C'?
    Hope you guys can help?

    Various languages distinct sorting - collation - sequences. 
    The characters can and variously do sort differently, depending on what language is involved. 
    Languages here can include the written languages of humans, and a few settings associated with programming languages.  This is all part of what is known as internationalization and localization, and there are are various documents around on that topic.
    The LC_ALL environment variable sets all of the locale-related settings en-mass, including the collation sequence that is established via LC_COLLATE et al, and the sort tool is suggesting selecting the C language collation.
    Here, the tool is suggesting the following syntax:
    LC_ALL=C sort -u words.txt > words1.txt
    This can also be done by exporting the LC_ALL, but it's probably better to just do this locally before invoking the tool.
    Also look at the lines of text in question within the files, and confirm the character encoding of the file.
    Files can have different character encodings, and there's no reliable means to guess the encoding.  For some related information, see the file command:
    file words.txt
    ...and start reading some of the materials on internationalization and localization that are posted around the 'net. Here's Apple's top-level overview.
    In this case, it looks like there's an "odd" character and probably an å character on that line and apparently the Svenska ariadnetrådens. 
    Switching collation can help here, or - if the character is not necessary - removing it via tr or replacing it via sed can be equally effective solutions. 
    Given it appears to be Svenska, it might work better to switch to Svenska collation thanto  the suggested C collation.
    I think that's going to be sv_SE, which would make the command:
    LC_ALL=sv_SE sort -u words.txt > words1.txt
    This is all generic bash shell scripting stuff, and not specific to OS X.  If you haven't already seen them, the folks over at tldp have various guides including a bash guide for beginners, and an advanced bash scripting guide - both can be worth skimming.  They're not exactly the same as bash on OS X and some specific commands and switches can differ, and as bash versions can differ, but bash is quite similar across all the platforms.

  • Help with bash function(set background=dark/light in vimrc)

    I couldn't find any gvimrc files so I guess it uses the regular one. And since I work pretty much in X too  I thought it would be nice with a function that sets background=light if I'm in X an background=dark if not. Is that possible?
    /Richard

    vimrc configuration is not the same as bash.
    You probably want something like this in your ~/.vimrc:
    if has('gui_running')
    set background=light
    else
    set background = dark
    endif

  • Need help with doing double sided printing!!!

    i have a Epson XP-100 priniter and also MacBook pro laptop
    i am having serious trouble with doing double side printing
    can somebody assist me through please
    thanks

    Read the user manual that came w/the printer.  It will tell you if double sided printing is compatible w/your current OS which you did not mention.  If not, you will need to contact Epson tech support and/or post in their forums if they have one. 

  • Help with hp 7520 wireless printer does not recognize black photo ink

    brand new 7520 hp photosmart wireless printer . i set it up put in all set up ink cartridges correctly. machine says missing cartridge shows photo of black photo ink . this machine is not recognizing the ink. i heard it snap in and i see it but this wireless photosmart 7520 wireless printer is not smart enough to recognize its own set up photo black ink ive tried everything i even went to staples and purchased a new  photo black ink. put it in and again it states that it is missing. any suggestions before i throw it in the trash where a stupid machine belongs many thanks

    Hello @notrevo157,
    Welcome to the HP Support Forums! I see you are setting up your HP Photosmart 7520 and it is not recognizing the Black setup cartridge. You have tried replacing the cartridge with no success.
    I would like you to start troubleshooting here: Ink Cartridge Problem: An 'Ink Cartridge Problem,' 'Incompatible Ink Cartridge,' or 'Ink Cartridge F..., I understand you may not be getting this exact error message however these are the steps I would like you to do to try and resolve the issue you are experiencing.
    If after the troubleshooting you are still experiencing the issue, I would call our technical support at 800-474-6836 as you may need the setup cartridge replaced. If you live outside the US/Canada Region, please click the link below to get the support number for your region. http://www8.hp.com/us/en/contact-hp/ww-phone-assist.html
    I hope this helps!
    Thanks,
    HevnLgh
    I work on behalf of HP
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to the left of the reply button to say “Thanks” for helping!

  • Help with Hasvalue Function in 2008

    Dear all,
    I have a question regarding "Hasvalue" function under Crystal Reports 2008. I have created a quite extensive report based on quite alot of parameters. These parameters need to be Optional i.e. if user does not enter a value then all the records according to date parameter should be chosen, however if any one parameter value has been entered then report should filter according to that parameter value as well as date parameter values.
    The report prints out results fine however it takes quite a lot of time to load. Example would be, yesterday when I ran the report Database query took 87238ms and reading records took 30691ms hence report formatting a first page took 981428ms.
    Upon research and help from Brian in this forum I found out that while using "Hasvalue" the even when I use parameter value in one of the parameters, only date parameters are getting passed through the SQL query to the database, rest are not passed meaning that it reads all the records and then sort them in the end.
    I have only one parameter which is not optional and that is date parameter, rest all are optional.
    My question is, how can I pass the parameter values when chosen through the SQL query so that it can search the db upon query and not read all the records and sort at last.
    Any ideas how to make it work?
    Many thanks
    Regards
    Jehanzeb

    On the report under Report>Record->Selection formula.
    Infact here is the formula
    {order_header.date_entered} >= {?Start Date} and
    {order_header.date_entered} <= {?End Date} and
    (not HasValue({?Account Number}) or {order_header.account_no} = {?Account Number})and
    (not HasValue({?Product Group}) or {order_lines.stock_code}[1 to 5] = {?Product Group})and
    (not HasValue({?Sales Area}) or {slslsp.slr_slsperson} in {?Sales Area});
    All the Hasvalue are not being passed on through SQL, as you can see below I have chosen a customer account number but it does not reflect in the query, however the results are according to customer account.
    SELECT DISTINCT order_header.order_no, order_header.order_status, order_header.date_entered,
    ndmas.ndm_name, order_header.account_no, order_progress.order_status, order_lines.stock_code,
    slslsp.slr_slsperson, slslsp.slr_slspname, order_progress.date_created
    FROM   maxmast.ndmas ndmas, maxmast.order_header order_header, maxmast.order_lines order_lines,
    maxmast.order_progress order_progress, maxmast.slcust slcust, maxmast.slslsp slslsp
    WHERE  (order_header.order_no=order_lines.order_no) AND
    ((order_header.order_no=order_progress.order_no) AND (order_header.repeat_no=order_progress.repeat_no))
    AND (order_header.account_no=slcust.slm_custcode) AND (ndmas.ndm_ndcode=slcust.slm_custcode) AND
    (slcust.slm_slsperson=slslsp.slr_slsperson) AND (order_header.date_entered>={ts '2008-10-01 00:00:00'}
    AND order_header.date_entered<={ts '2008-10-05 00:00:00'})
    Regards
    Jehanzeb

  • NEED HELP with HP P1006 DUPLEX printing

    This printer has the ability to print duplex pages (manual).
    This is different from printing the odd pages and then the even pages to achieve two-sided pages.
    This affects me because I like to print 2-sided AND print 2 pages on each side and the manual odd/even trick messes up the page order because I will end up with the first and third pages on one side of the paper and the second and fourth pages on the other side. Essentially I was able to print 4 pages onto 1 sheet of paper.
    Please help me save paper!! I am a grad student and I do a lot of printing!!!
    Other information:
    1. I have the latest driver updates.
    2. I can see the option for two-sided printing but it is grayed out and set on "off"
    3. I know for a fact that my printer has this property-- it is marketed as having manual duplex printing (plus it worked fine with windows vista on my pc with the CD software)
    4. What I've learned so far is that the latest driver is not "clever" enough to enable the duplex printing and there are no plans to make it better WHICH I HOPE IT NOT TRUE!!!
    Please help genius or Apple gods.
    Thank you!

    rosh325,
    The HP Photosmart C4280 does support manual duplex printing (as do all of the devices). The request on this thread is specific to a special form of manual duplex printing that these devices used to support (but on the Mac your device does not). To get the Manual duplexing, you can Print Odd pages, take the paper out, place it back in your input tray, and then print even pages. Just take the whole stack from the output tray and place it so you can see the printing and its right side up when you put it in your input tray. (You may want to experiment with a small document just to make sure you have the workflow down).
    As for button support, install the full solution for your device from [here|http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=oj- 74785-1&lc=en&dlc=en&cc=us&lang=en&os=219&product=3192753] and it should restore the button functionality.
    Just trying to help.
    Andrew

  • Help with main function

    Can someone help me out with this? Im trying to create a main function out of this contructor.
    public studentID()
    int size; //hold returned values from box
    int id;
    int age;
    size = Integer.parseInt(JOptionPane.showInputDialog (" Enter a nummber between 1 & 40")); //dialog box
    recCount = 0;
    idArray = new int[size];
    ageArray = new int[size];
    for(int i = 0; i <size; i++) //ask for values (size) times
    id =
    Integer.parseInt(JOptionPane.showInputDialog ("Enter an ID Number"));
    age =
    Integer.parseInt(JOptionPane.showInputDialog ("Enter an age"));
    inputStudent(age, id); //calles method to put values in array
    displayAll();
    selectionSort(idArray, ageArray, size);
    newNumberTable();
    selectionSort(ageArray, idArray, size);
    newAgeTable();
    }

    So what's the problem? Dump it all into the main method.
    Actually I'd advise thinking carefully about whether it should really be in main(). Generally, IMHO, main should only bootstap an app. The real functionality should be in other methods that main() calls.

Maybe you are looking for

  • How can I start Private Browsing when I do not have a "Firefox button" to click?

    "Open a new, blank Private Window At the top of the Firefox window, click the Firefox button and select New Private Window. A new Private Window will open. That is what it says! But where is this Firefox button at the top of my Firefox (v 20.0.1) win

  • The Usage decision cancellation & quantity reversal

    Daer All, While cancelling the Goods receipt, system gives the error Deficit of SL Stck.in qual.insp 10 M : 5000017/1 PMT1 RMST as the usage decision of quality lot generated for the goods receipt is done. I want to cancel/reverse the usage decision

  • Report with Row Edit capability

    When creating a report, what are the components that enable row edit capability. A few basic reports I generate do not have this capability. How would I change an existing report to allow row edits and then linking to a form to edit content. Thanks,

  • Incompatible sim

    iphone doesn't work - says incompatible sim card and comes up with these numbers: IMEI 01 147200 520598 2 ICCID 8961 0153 7600 5500 0063 HELP!

  • Temse files not deleted

    Hi all, After housekeeping of job logs via report RSBTCDEL2, the job logs are deleted in SAP but temse files in unix are not deleted.  Temse consistency check does not indicate any problem, what could be the cause?