India Broadband Forum


programming challenge...

This is a discussion on programming challenge... within the Entertainment and Recreation forums, part of the General offtopic discussions category; OK, I have done a quick and dirty solution. I won't post the source code till others have finished. > ...

Go Back   India Broadband Forum > General > General offtopic discussions > Entertainment and Recreation

India Broadband Forum


Entertainment and Recreation Everything related to entertainment like movies, jokes and other funny stuff goes here

                      

Reply

 

LinkBack Thread Tools Display Modes
Old 08-06-09, 12:16 AM   #21
Platinum Member
 
Join Date: Sep 2008
Posts: 3,140
Rep Power: 10
Punch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to all
Default

OK, I have done a quick and dirty solution. I won't post the source code
till others have finished.

> !cc
cc ddd.c
> a.out
source = 0, row = 0, col = 0, nr = 0, nc = 0
source = 1, row = 1, col = 0, nr = 1, nc = 0
source = 2, row = 0, col = 1, nr = 1, nc = 0
source = 3, row = 2, col = 0, nr = 2, nc = 0
source = 4, row = 1, col = 1, nr = 2, nc = 0
source = 5, row = 0, col = 2, nr = 2, nc = 0
source = 6, row = 3, col = 0, nr = 3, nc = 0
source = 7, row = 2, col = 1, nr = 3, nc = 0
source = 8, row = 1, col = 2, nr = 3, nc = 0
source = 9, row = 0, col = 3, nr = 3, nc = 0
source = 10, row = 3, col = 1, nr = 3, nc = 1
source = 11, row = 2, col = 2, nr = 3, nc = 1
source = 12, row = 1, col = 3, nr = 3, nc = 1
source = 13, row = 3, col = 2, nr = 3, nc = 2
source = 14, row = 2, col = 3, nr = 3, nc = 2
source = 15, row = 3, col = 3, nr = 3, nc = 3
acfj
beim
dhlo
gknp
>
Punch Farce is offline   Reply With Quote
Old 08-06-09, 12:20 AM   #22
Gold Member
 
nandini's Avatar
 
Join Date: Jun 2009
Location: Pune
Posts: 487
Rep Power: 3
nandini is a jewel in the roughnandini is a jewel in the roughnandini is a jewel in the rough
Default

Good job Farce!!!


Did you find it challenging?
nandini is offline   Reply With Quote
Old 08-06-09, 12:27 AM   #23
newprouser
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by farce View Post
OK, I have done a quick and dirty solution. I won't post the source code
till others have finished.

> !cc
cc ddd.c
> a.out
source = 0, row = 0, col = 0, nr = 0, nc = 0
source = 1, row = 1, col = 0, nr = 1, nc = 0
source = 2, row = 0, col = 1, nr = 1, nc = 0
source = 3, row = 2, col = 0, nr = 2, nc = 0
source = 4, row = 1, col = 1, nr = 2, nc = 0
source = 5, row = 0, col = 2, nr = 2, nc = 0
source = 6, row = 3, col = 0, nr = 3, nc = 0
source = 7, row = 2, col = 1, nr = 3, nc = 0
source = 8, row = 1, col = 2, nr = 3, nc = 0
source = 9, row = 0, col = 3, nr = 3, nc = 0
source = 10, row = 3, col = 1, nr = 3, nc = 1
source = 11, row = 2, col = 2, nr = 3, nc = 1
source = 12, row = 1, col = 3, nr = 3, nc = 1
source = 13, row = 3, col = 2, nr = 3, nc = 2
source = 14, row = 2, col = 3, nr = 3, nc = 2
source = 15, row = 3, col = 3, nr = 3, nc = 3
acfj
beim
dhlo
gknp
>
ippadi pannitingale annan
  Reply With Quote
Old 08-06-09, 12:29 AM   #24
Platinum Member
 
Join Date: Sep 2008
Posts: 3,140
Rep Power: 10
Punch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to all
Default

Quote:
Originally Posted by nandini View Post
Good job Farce!!!


Did you find it challenging?
Yes, it was challenging, since it took me a few iterations to
get the logic right, and still I think I should improve the code
and make it more elegant ;-) next version coming up soon.

-F

Quote:
Originally Posted by newprouser View Post
ippadi pannitingale annan
I didn't post the source code, so you have no idea how I did it ;-)
I could have hardcoded the entire thing ;-)
sorry, please continue with your coding, don't stop.

-F

Last edited by Punch Farce; 08-06-09 at 12:29 AM. Reason: Automerged Doublepost
Punch Farce is offline   Reply With Quote
Old 08-06-09, 12:35 AM   #25
Gold Member
 
nandini's Avatar
 
Join Date: Jun 2009
Location: Pune
Posts: 487
Rep Power: 3
nandini is a jewel in the roughnandini is a jewel in the roughnandini is a jewel in the rough
Default

Quote:
Originally Posted by farce View Post
Yes, it was challenging, since it took me a few iterations to
get the logic right, and still I think I should improve the code
and make it more elegant ;-) next version coming up soon.

-F

hmmnnn...
This problem was asked in the interview which I missed last week.
nandini is offline   Reply With Quote
Old 08-06-09, 12:39 AM   #26
newprouser
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by farce View Post
I didn't post the source code, so you have no idea how I did it ;-)
I could have hardcoded the entire thing ;-)
sorry, please continue with your coding, don't stop.

-F
I found the sequence easily. just testing is taking time. i lost touch with programming , gotta practice more.

i'm coding in c++ only anyways.

nandini, don't stop with this please
  Reply With Quote
Old 08-06-09, 12:45 AM   #27
Gold Member
 
nandini's Avatar
 
Join Date: Jun 2009
Location: Pune
Posts: 487
Rep Power: 3
nandini is a jewel in the roughnandini is a jewel in the roughnandini is a jewel in the rough
Default

Quote:
Originally Posted by newprouser View Post
I found the sequence easily. just testing is taking time. i lost touch with programming , gotta practice more.

i'm coding in c++ only anyways.

nandini, don't stop with this please
sure!!
would love to know what your logic is. We can definitely learn out of this. Well you finish with the coding first. I did it in Java.

I'll surely post problem that tests our analytical thinking and expects the same from you guys as well.
nandini is offline   Reply With Quote
Old 08-06-09, 12:52 AM   #28
Jedi knight
 
Luke Skywalker's Avatar
 
Join Date: Jul 2009
Location: IBF
Age: 21
Posts: 1,818
Rep Power: 5
Luke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the rough
Default

Doing was writing a poem earlier.
Luke Skywalker is offline   Reply With Quote
Old 08-06-09, 01:02 AM   #29
Platinum Member
 
Join Date: Sep 2008
Posts: 3,140
Rep Power: 10
Punch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to all
Default

take a string = "abcdefgh";

reverse this without using any temp variables ;-)

-F
Punch Farce is offline   Reply With Quote
Old 08-06-09, 01:07 AM   #30
Pri_dm
Guest
 
Posts: n/a
Default

give me 30 -60 mins
  Reply With Quote
Old 08-06-09, 01:08 AM   #31
Gold Member
 
nandini's Avatar
 
Join Date: Jun 2009
Location: Pune
Posts: 487
Rep Power: 3
nandini is a jewel in the roughnandini is a jewel in the roughnandini is a jewel in the rough
Default

Quote:
Originally Posted by farce View Post
take a string = "abcdefgh";

reverse this without using any temp variables ;-)

-F
just to be sure...

don't we have to use any kind of temp variable?
nandini is offline   Reply With Quote
Old 08-06-09, 01:12 AM   #32
Platinum Member
 
Join Date: Sep 2008
Posts: 3,140
Rep Power: 10
Punch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to all
Default

Quote:
Originally Posted by Pri_dm View Post
give me 30 -60 mins
Just post the output of the run, not the source code till
everone has a chance to attempt it.

thanks
-F

Quote:
Originally Posted by nandini View Post
just to be sure...

don't we have to use any kind of temp variable?
actually I am not sure, I remember this being asked in an interview
(with Cisco I think) and I did it at that time.

Let's start trying with NO temp variables and then if that is
impossible then we can use one.

as usual post the results first and then the code after everyone completes.

-F

Last edited by Punch Farce; 08-06-09 at 01:12 AM. Reason: Automerged Doublepost
Punch Farce is offline   Reply With Quote
Old 08-06-09, 01:21 AM   #33
Gold Member
 
nandini's Avatar
 
Join Date: Jun 2009
Location: Pune
Posts: 487
Rep Power: 3
nandini is a jewel in the roughnandini is a jewel in the roughnandini is a jewel in the rough
Default

Did you do it in c/c++, using pointers?
A simple yes/no will do? lol
nandini is offline   Reply With Quote
Old 08-06-09, 01:26 AM   #34
Jedi knight
 
Luke Skywalker's Avatar
 
Join Date: Jul 2009
Location: IBF
Age: 21
Posts: 1,818
Rep Power: 5
Luke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the rough
Default

funny output:
a e i m
b f j n
c g k o
d h l p

I was spoon fed this problem.

Last edited by Luke Skywalker; 08-06-09 at 01:26 AM. Reason: Automerged Doublepost
Luke Skywalker is offline   Reply With Quote
Old 08-06-09, 01:26 AM   #35
Platinum Member
 
Join Date: Sep 2008
Posts: 3,140
Rep Power: 10
Punch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to all
Default

Quote:
Originally Posted by nandini View Post
Did you do it in c/c++, using pointers?
A simple yes/no will do? lol
no,

actually let me amend my condition, I think you can use variables
for loops etc. like for (i = ..., max) etc.
Just not a temp variable to store letters from that string.

-F
Punch Farce is offline   Reply With Quote
Old 08-06-09, 01:32 AM   #36
Jedi knight
 
Luke Skywalker's Avatar
 
Join Date: Jul 2009
Location: IBF
Age: 21
Posts: 1,818
Rep Power: 5
Luke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the roughLuke Skywalker is a jewel in the rough
Default

But can't recall the answer.

trying with unicode give 45 min more.

Last edited by Luke Skywalker; 08-06-09 at 01:32 AM. Reason: Automerged Doublepost
Luke Skywalker is offline   Reply With Quote
Old 08-06-09, 01:35 AM   #37
Platinum Member
 
Join Date: Sep 2008
Posts: 3,140
Rep Power: 10
Punch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to all
Default reverse

I am really really impressed with myself ;-)

I rememebered 3 lines of code I did in an interview 10 years back!

> !cc
cc rrr.c
> a.out
before = abcdefgh
after = hgfedcba
>
Punch Farce is offline   Reply With Quote
Old 08-06-09, 01:37 AM   #38
Gold Member
 
nandini's Avatar
 
Join Date: Jun 2009
Location: Pune
Posts: 487
Rep Power: 3
nandini is a jewel in the roughnandini is a jewel in the roughnandini is a jewel in the rough
Default

Don't give us complexion, Farce.
nandini is offline   Reply With Quote
Old 08-06-09, 01:40 AM   #39
Platinum Member
 
Join Date: Sep 2008
Posts: 3,140
Rep Power: 10
Punch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to allPunch Farce is a name known to all
Default

Quote:
Originally Posted by nandini View Post
Don't give us complexion, Farce.


Nandini, if it means anything I think you are very much like me
technically and attitude-wise. Trust me, you are going to remember
this challenge 10 years from now ;-)

-F
Punch Farce is offline   Reply With Quote
Old 08-06-09, 01:45 AM   #40
Gold Member
 
nandini's Avatar
 
Join Date: Jun 2009
Location: Pune
Posts: 487
Rep Power: 3
nandini is a jewel in the roughnandini is a jewel in the roughnandini is a jewel in the rough
Default

Quote:
Originally Posted by farce View Post


Nandini, if it means anything I think you are very much like me
technically and attitude-wise. Trust me, you are going to remember
this challenge 10 years from now ;-)

-F
Alrighto!!!

I'll give it a try tomorrow. I am so tired that I can't concentrate.
nandini is offline   Reply With Quote
Reply

Tags
challenge, programming

Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Vote: would you like to have a programming section in IBF ? newprouser Suggestions and Complaints 30 08-30-09 12:56 AM
Java Programming : Doubts newprouser Windows 20 08-19-09 11:20 PM
Tata Sky Plus challenge devrajofjaipur Tata sky 2 05-20-09 01:50 PM
Any how to videos for Flash Programming? vishnu54 Windows 0 05-06-09 05:28 PM


All times are GMT +5.5. The time now is 11:15 PM.


India Broadband Forum