Results 1 to 5 of 5

Thread: [OFFTOPIC]: Problem for hardcore programmers!

  1. #1
    Member
    Join Date
    Jan 2007
    Location
    Moscow
    Posts
    239
    Thanks
    0
    Thanked 3 Times in 1 Post
    Excuse me for offtopic!
    Some fellow at my work gave us such a problem:
    ******************************
    Please fix the program below with only one symbol change:
    you may add one character
    or
    you may delete one character
    or
    you may replace one character

    // the program must print 20 stars
    main()
    {
    int i, N = 20;
    for(i = 0 ; i < N ; i--)
    printf("*");
    }

    There are three known solutions.
    ************************

    I've managed to find only one
    Can you help me?

  2. #2
    Programmer Bulat Ziganshin's Avatar
    Join Date
    Mar 2007
    Location
    Uzbekistan
    Posts
    4,497
    Thanks
    733
    Thanked 659 Times in 354 Posts
    -i<N
    N--

    any solution should change either i<N or i-- part, so i'm pretty sure that no more solutions exist

  3. #3
    Member
    Join Date
    Jan 2007
    Location
    Moscow
    Posts
    239
    Thanks
    0
    Thanked 3 Times in 1 Post
    Third is
    i + N
    Some guy solved this in 8 minutes

  4. #4
    Programmer Bulat Ziganshin's Avatar
    Join Date
    Mar 2007
    Location
    Uzbekistan
    Posts
    4,497
    Thanks
    733
    Thanked 659 Times in 354 Posts
    ...

  5. #5
    Member
    Join Date
    Dec 2006
    Posts
    611
    Thanks
    0
    Thanked 1 Time in 1 Post
    Sorry Bulat You were twice slower
    Just joking

Similar Threads

  1. Thread title changeable? - No Problem!
    By Simon Berger in forum The Off-Topic Lounge
    Replies: 13
    Last Post: 7th January 2016, 11:53
  2. Help me!!! Visual Basic programmers needed
    By moisesmcardona in forum The Off-Topic Lounge
    Replies: 1
    Last Post: 27th June 2009, 20:46
  3. Hardcore will never die!
    By encode in forum The Off-Topic Lounge
    Replies: 7
    Last Post: 8th July 2008, 22:09
  4. Sudden offtopic
    By Shelwien in forum Forum Archive
    Replies: 1
    Last Post: 20th April 2008, 21:05
  5. Problem with forum
    By EneergE in forum Forum Archive
    Replies: 1
    Last Post: 28th March 2008, 12:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •