[algogeeks] Re: Mutex

2011-06-17 Thread MONSIEUR
@DK: absolutely..actually mutex is a kinda semaphore...and unlike
semaphores it does not have any list(of waiting processes) associated
with it and just is a kind of lock and key model with no waiting
Q.someone can say that they are Binary semaphore since binary
semaphore have only two values 0/1 thus no waiting Q and behave like
mutex


On Jun 18, 1:58 am, DK  wrote:
> @Dumanshu/@Ankit: Of course mutexes can be made to work between processes
> (it's an implementation detail). But the *concept* of a mutex is Owner +
> (Lock & Key) pair. By adding the concept of Owner to a lock, we can ensure
> that only the person who locked the lock can open it. This *guarantees*
> mutual exclusion (which is unlike a semaphore). A semaphore is a signalling
> mechanism between threads/processes that simply indicates an event that has
> occured asynchronously to the process/thread's flow of control (for
> processes/threads other than the event generating process of-course). It is
> often used to indicate that cooperative progress may be possible on
> resources under contention or synchronization between states may be
> required. Any cooperating process/thread can modify the value of a semaphore
> which is not true of a mutex.
>
> Note: Mutex and Semaphore are essentially concepts. Their implementations
> can vary in different systems and have different implementation constraints
> but the theory is clear. The two are different and serve different purposes
> though they may share implementation details.
>
> --
> DK
>
> http://twitter.com/divyekapoorhttp://www.divye.in

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Output please..

2011-06-17 Thread Harshal
compiler error?? if the void is replaced by int, ans=155.

On Sat, Jun 18, 2011 at 11:33 AM, Balaji S  wrote:

> main()
>  { int i=5;
>  printf("%d",fun(fun(fun(fun( fun(i));
> }
>  void fun (int i)
>  {
> if(i%2)
> return (i+(7*4)-(5/2)+(2*2));
>  else
>
>
> return (i+(17/5)-(34/15)+(5/2));
> }
>
>
>
> --
> With Regards,
> Balaji.S
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Harshal Choudhary,
III Year B.Tech CSE,
NIT Surathkal, Karnataka, India.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Finding the min gap in 3 arrays

2011-06-17 Thread Harshal
@Dumanshu:
min dist: you will terminate the algo when atleast 2 of the lists have their
indices reached the end of their respective lists in the process.
On Sat, Jun 18, 2011 at 12:37 AM, Dumanshu  wrote:

> @Harshal: your terminating condition would be -
> lets say we have set the pointers to index 0 of each to get the min
> distance.
> for index 0 set the min_dist overall to the max distance among the 3
> pairs. Now increase the pointer with the minimum value and check the
> max distance between pairs. If distance now is more than min_dist we
> terminate and we have the answer
> else continue incrementing the pointer with the minimum value until we
> get a distance value greater than the previously computed min_dist
> value.
> correct me if i have misinterpreted ur algo.
>
> On Jun 17, 10:08 pm, Harshal  wrote:
> > I think this will work,
> > have 3 pointers p,q,r pointing last elements of the 3 lists.
> > compute the difference between each pair.
> > decrement the index of the list having the min element.
> > (at each stage, save the current indices and current max distance).
> >
> > Same logic for the min distance part, just start from index 0.
> >
> >
> >
> >
> >
> > On Fri, Jun 17, 2011 at 9:43 PM, Ashish Goel  wrote:
> > > merge two and if required third  array keeping array tag with the
> elements
> > > walk over the merged list and see adjacent distance which is minimum
> with
> > > the condition that the tage of the adjacent elements are different
> >
> > > Best Regards
> > > Ashish Goel
> > > "Think positive and find fuel in failure"
> > > +919985813081
> > > +919966006652
> >
> > > On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu  wrote:
> >
> > >> U have got 3 sorted arrays A1 A2 and A3 having m n and p elements
> > >> respectively. A gap of 3 arrays is defined to be max distance between
> > >> 3 nos if they are put on a no line say u pick three 2 12 and 7 then
> > >> the gap is 10. Now u have to find an efficient way of chosing 3 nos
> > >> from these 3 seperate arrays (A1, A2, A3) such that their gap is
> > >> minimum. Of course if a num say 2 occurs in all 3 then gap is 0!!!
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Algorithm Geeks" group.
> > >> To post to this group, send email to algogeeks@googlegroups.com.
> > >> To unsubscribe from this group, send email to
> > >> algogeeks+unsubscr...@googlegroups.com.
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/algogeeks?hl=en.
> >
> > >  --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algogeeks@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > --
> > Harshal Choudhary,
> > III Year B.Tech CSE,
> > NIT Surathkal, Karnataka, India.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Harshal Choudhary,
III Year B.Tech CSE,
NIT Surathkal, Karnataka, India.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Output please..

2011-06-17 Thread Balaji S
main()
 { int i=5;
 printf("%d",fun(fun(fun(fun( fun(i));
}
 void fun (int i)
 {
if(i%2)
return (i+(7*4)-(5/2)+(2*2));
 else

return (i+(17/5)-(34/15)+(5/2));
}



-- 
With Regards,
Balaji.S

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] STL MAP HELP

2011-06-17 Thread nicks
Is it Possible to Sort the stl map on the basis of values though they are
sorted internally on the basis of index ???

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: How to use asm in spoj

2011-06-17 Thread Gene
Spoj uses -O2 -fomit-frame-pointer when it compiles.  Could that be it? 
 Maybe the %1 and %2 don't work with this option.  Just a guess...

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/eoTGaR6v1xIJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: google interview c testing

2011-06-17 Thread rahul
strangegoogle ask these type of question too.

On Sat, Jun 18, 2011 at 3:07 AM, DK  wrote:

> using: delete[] arrayPointer;
>
> --
> DK
>
> http://twitter.com/divyekapoor
> http://www.divye.in
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/1C5XEl8FfiYJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: How to use asm in spoj

2011-06-17 Thread saurabh singh
I am using standard gcc 4.3.2 and the code does not requires any flag to be
required.I also checked the alias if gcc has been aliased to be used with
some option,but that was not the case.My operating system is ubuntu.The
error I get is "CONT1D and D1ONE already defined.
I wonder if spoj has a modified gcc which uses the nasm assembler instead of
the standard assembler packed with gcc?I have put the problem on spoj forum
few days back but no one has replied since
On Sat, Jun 18, 2011 at 3:06 AM, DK  wrote:

> What compiler are you using? Version, compile options etc.
>
> --
> DK
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/Wf2PvNNjTikJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: google interview c testing

2011-06-17 Thread DK
using: delete[] arrayPointer;

--
DK

http://twitter.com/divyekapoor
http://www.divye.in

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/1C5XEl8FfiYJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: How to use asm in spoj

2011-06-17 Thread DK
What compiler are you using? Version, compile options etc.

--
DK

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/Wf2PvNNjTikJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Minimum Rotations

2011-06-17 Thread DK
Optimization options:
1. Don't double the string length. You can use the mod operator (might or 
might not be an optimization - profile and see).
2. Work only with indices. There is no need to create a reference to a slice 
of the string during each loop pass that checks the "if" condition. That 
statement might be creating a copy of the string (I don't know if psyco does 
copy on write for substrings). Besides, you only need the index of the 
string.
3. There's a reference to the string slice created inside the loop too. You 
really don't need the reference if you're storing the index value.

You could also look at simple optimizations like checking if the next 
character is smaller than the current one, so skipping the testing of the 
substring as the next one is guaranteed to be a better candidate.

Hope this helps.

--
DK

http://twitter.com/divyekapoor
http://www.divye.in



-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/simQ8C9YCocJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Need an Algorithm Recommendation

2011-06-17 Thread DK
Hi Rodrigo,
   There's a complete field: "Data Mining" that deals with questions like 
these. There are a class of algorithms called "recommender" algorithms that 
analyze past purchase history of a user to make future predictions of items 
of interest (similar to the ones implemented on Ebay, Amazon etc. where they 
earn big bucks by figuring out what a customer would buy). However, if 
you're inexperienced or looking at just starting out with simple 
recommendations, I would suggest that you sit down with ecommerce data from 
your site and make the following analysis manually:

1. What items are frequently bought together? Place them in close proximity 
on your site. (See the Apriori and FP Tree algorithms for simple algorithms 
for the same. You could also look at clustering algorithms if you have data 
that is amenable to such analysis)

2. If a user has bought certain items, what are the items he would be likely 
to be interested in? (See Classifiers of various kinds to derive predictive 
rules from the frequently bought together dataset of step 1 - Bayesian 
Classification, Rule Based Classification, Decision Tree classification - 
there are a number of options available).

I hope this helps. Let me know if you need more information about this.

--
DK

Follow me on Twitter:
http://twitter.com/divyekapoor
http://www.divye.in

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/XMGrNGn55k4J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Mutex

2011-06-17 Thread DK
@Dumanshu/@Ankit: Of course mutexes can be made to work between processes 
(it's an implementation detail). But the *concept* of a mutex is Owner + 
(Lock & Key) pair. By adding the concept of Owner to a lock, we can ensure 
that only the person who locked the lock can open it. This *guarantees* 
mutual exclusion (which is unlike a semaphore). A semaphore is a signalling 
mechanism between threads/processes that simply indicates an event that has 
occured asynchronously to the process/thread's flow of control (for 
processes/threads other than the event generating process of-course). It is 
often used to indicate that cooperative progress may be possible on 
resources under contention or synchronization between states may be 
required. Any cooperating process/thread can modify the value of a semaphore 
which is not true of a mutex.

Note: Mutex and Semaphore are essentially concepts. Their implementations 
can vary in different systems and have different implementation constraints 
but the theory is clear. The two are different and serve different purposes 
though they may share implementation details.

--
DK

http://twitter.com/divyekapoor
http://www.divye.in

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/ssXg1ahVXcgJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Finding the min gap in 3 arrays

2011-06-17 Thread Dumanshu
@Harshal: your terminating condition would be -
lets say we have set the pointers to index 0 of each to get the min
distance.
for index 0 set the min_dist overall to the max distance among the 3
pairs. Now increase the pointer with the minimum value and check the
max distance between pairs. If distance now is more than min_dist we
terminate and we have the answer
else continue incrementing the pointer with the minimum value until we
get a distance value greater than the previously computed min_dist
value.
correct me if i have misinterpreted ur algo.

On Jun 17, 10:08 pm, Harshal  wrote:
> I think this will work,
> have 3 pointers p,q,r pointing last elements of the 3 lists.
> compute the difference between each pair.
> decrement the index of the list having the min element.
> (at each stage, save the current indices and current max distance).
>
> Same logic for the min distance part, just start from index 0.
>
>
>
>
>
> On Fri, Jun 17, 2011 at 9:43 PM, Ashish Goel  wrote:
> > merge two and if required third  array keeping array tag with the elements
> > walk over the merged list and see adjacent distance which is minimum with
> > the condition that the tage of the adjacent elements are different
>
> > Best Regards
> > Ashish Goel
> > "Think positive and find fuel in failure"
> > +919985813081
> > +919966006652
>
> > On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu  wrote:
>
> >> U have got 3 sorted arrays A1 A2 and A3 having m n and p elements
> >> respectively. A gap of 3 arrays is defined to be max distance between
> >> 3 nos if they are put on a no line say u pick three 2 12 and 7 then
> >> the gap is 10. Now u have to find an efficient way of chosing 3 nos
> >> from these 3 seperate arrays (A1, A2, A3) such that their gap is
> >> minimum. Of course if a num say 2 occurs in all 3 then gap is 0!!!
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algogeeks@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/algogeeks?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> Harshal Choudhary,
> III Year B.Tech CSE,
> NIT Surathkal, Karnataka, India.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Finding the min gap in 3 arrays

2011-06-17 Thread Ashish Goel
say the arrays are

a 6,7,9
b 3,4,5
c 1,2,8


the merged array would be

1c
2c
3a
4b
5b
6a
7a
8c
9a

1c,2c cant be compared as they are from same array..next is 3a this implies
3-2 =1 is min distance

P.S: you can merge these in O(m+n+p) [merge from bottom as they are already
sorted]


Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652


On Sat, Jun 18, 2011 at 12:24 AM, Dumanshu  wrote:

> @Ashish: could u plz explain ur algo in detail. "walk over the merged
> list to get adjacent min distance and different tags" this would be of
> the order O(m*n) say we merge A1 A2 of size m and n respectively.
> Also, now how do u go ahead with the 3rd array? didn't get ur
> solution.
>
> Harshal's solution looks fine. ny bugs?
>
> On Jun 17, 9:13 pm, Ashish Goel  wrote:
> > merge two and if required third  array keeping array tag with the
> elements
> > walk over the merged list and see adjacent distance which is minimum with
> > the condition that the tage of the adjacent elements are different
> >
> > Best Regards
> > Ashish Goel
> > "Think positive and find fuel in failure"
> > +919985813081
> > +919966006652
> >
> >
> >
> > On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu  wrote:
> > > U have got 3 sorted arrays A1 A2 and A3 having m n and p elements
> > > respectively. A gap of 3 arrays is defined to be max distance between
> > > 3 nos if they are put on a no line say u pick three 2 12 and 7 then
> > > the gap is 10. Now u have to find an efficient way of chosing 3 nos
> > > from these 3 seperate arrays (A1, A2, A3) such that their gap is
> > > minimum. Of course if a num say 2 occurs in all 3 then gap is 0!!!
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algogeeks@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Mutex

2011-06-17 Thread Dumanshu
@Ankit: it seems like mutexes can work between processes. refer to
http://geeksforgeeks.org/?p=9102   m i right?

On Jun 17, 5:56 pm, ankit sambyal  wrote:
> Yes, even the threads of a single process cannot have access to each
> others mutex.
> Mutexes can be applied only to threads in a single process and do not
> work between processes as do semaphores.
>
> On Fri, Jun 17, 2011 at 5:40 AM, Akshata Sharma
>
>
>
>  wrote:
> > When a thread locks a mutex only it can unlock it. Does this implies that
> > even the threads of a single process cannot have access to each others
> > mutex? I mean, if a thread A of process P has acquired a mutex, then only
> > thread A can release it or a thread B of same process P can also release it?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Finding the min gap in 3 arrays

2011-06-17 Thread Dumanshu
@Ashish: could u plz explain ur algo in detail. "walk over the merged
list to get adjacent min distance and different tags" this would be of
the order O(m*n) say we merge A1 A2 of size m and n respectively.
Also, now how do u go ahead with the 3rd array? didn't get ur
solution.

Harshal's solution looks fine. ny bugs?

On Jun 17, 9:13 pm, Ashish Goel  wrote:
> merge two and if required third  array keeping array tag with the elements
> walk over the merged list and see adjacent distance which is minimum with
> the condition that the tage of the adjacent elements are different
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
>
> On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu  wrote:
> > U have got 3 sorted arrays A1 A2 and A3 having m n and p elements
> > respectively. A gap of 3 arrays is defined to be max distance between
> > 3 nos if they are put on a no line say u pick three 2 12 and 7 then
> > the gap is 10. Now u have to find an efficient way of chosing 3 nos
> > from these 3 seperate arrays (A1, A2, A3) such that their gap is
> > minimum. Of course if a num say 2 occurs in all 3 then gap is 0!!!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS

2011-06-17 Thread Ashish Goel
will this work 4

axxbxba
chars r a,b in this str
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652


On Fri, Jun 17, 2011 at 11:47 PM, sunny agrawal wrote:

> Try this:
>
> say i is the index of the first occurrence of the first character
> say j is the index of the first occurrence of the second character
> say n is length of array
> int Min = n+1;
>
> while(i < n && j < n){
> int Min = min(Min, abs(i-j))
> if(i < j){
> find next occurrence of first character
> }
> else{
> find next occurrence of second character
> }
> }
>
> On 6/17/11, Harshal  wrote:
> > Given a character array with a set of characters, there might be
> repetitions
> > as well, given two characters, you should give the minimum distance
> between
> > these two characters in the whole array. O(n) solution is required.
> >
> > --
> > Harshal Choudhary,
> > III Year B.Tech CSE,
> > NIT Surathkal, Karnataka, India.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS

2011-06-17 Thread Ashish Goel
issue

axxbabxabaxxb

this solution will not work


rewriting, this should work...




int minD( char []a, const int &n, const char &a1, const char &b1)
int i=0;
int j=n-1;
int mind=-1;
while (i wrote:

> keep 4 pointers
>
> la, lb ra, rb
>
>
> la = -1; lb=-1; ra=n; rb=n;
> l stands for left side, r stands for right side
> a is first char b is second char
>
>
> int minD( char []a, const int &n, const char &a1, const char &b1)
> int i=0;
> int j=n-1;
> int mind=-1;
> while (i {
>   bool chkMin = false;
>   if (a[i] == a1)
>   {
>  if ((la==-1) || (lb==-1)){ la=i; chkMin = true;}
>   }
> else if (a[i] == b1)
> {
>  if ((la==-1) || (lb==-1)){ lb=i;chkMin = true;}
> }
>
>   if (a[j] == a1)
>   {
>  if ((ra==-1) || (rb==-1)){ ra=j;chkMin = true;}
>   }
> else if (a[j] == b1)
> {
>  if ((ra==n) || (rb==n)){ rb=j;chkMin = true;}
> }
>
>   if (chkMin)
>  {
>if ((la !=-1) && (lb != -1)) mind=min(mind, abs(la-lb));
>if ((ra !=n) && (rb != n)) mind=min(mind, abs(ra-rb));
>if ((la!=-1) &&(rb!=n)) mind=min(mind, abs(la-rb));
>if ((lb!=-1) &&(ra!=n)) mind=min(mind, abs(ra-lb));
>  }
> i++;j--;
> }
>
> return mind; //returns -1 if both chars not found
> }
>
>
> towards centre
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
>
> On Fri, Jun 17, 2011 at 11:15 PM, Harshal  wrote:
>
>> Given a character array with a set of characters, there might be
>> repetitions as well, given two characters, you should give the minimum
>> distance between these two characters in the whole array. O(n) solution is
>> required.
>>
>> --
>> Harshal Choudhary,
>> III Year B.Tech CSE,
>> NIT Surathkal, Karnataka, India.
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS

2011-06-17 Thread Ashish Goel
keep 4 pointers

la, lb ra, rb


la = -1; lb=-1; ra=n; rb=n;
l stands for left side, r stands for right side
a is first char b is second char


int minD( char []a, const int &n, const char &a1, const char &b1)
int i=0;
int j=n-1;
int mind=-1;
while (i wrote:

> Given a character array with a set of characters, there might be
> repetitions as well, given two characters, you should give the minimum
> distance between these two characters in the whole array. O(n) solution is
> required.
>
> --
> Harshal Choudhary,
> III Year B.Tech CSE,
> NIT Surathkal, Karnataka, India.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS

2011-06-17 Thread sunny agrawal
Try this:

say i is the index of the first occurrence of the first character
say j is the index of the first occurrence of the second character
say n is length of array
int Min = n+1;

while(i < n && j < n){
int Min = min(Min, abs(i-j))
if(i < j){
find next occurrence of first character
}
else{
find next occurrence of second character
}
}

On 6/17/11, Harshal  wrote:
> Given a character array with a set of characters, there might be repetitions
> as well, given two characters, you should give the minimum distance between
> these two characters in the whole array. O(n) solution is required.
>
> --
> Harshal Choudhary,
> III Year B.Tech CSE,
> NIT Surathkal, Karnataka, India.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] MS

2011-06-17 Thread Harshal
Given a character array with a set of characters, there might be repetitions
as well, given two characters, you should give the minimum distance between
these two characters in the whole array. O(n) solution is required.

-- 
Harshal Choudhary,
III Year B.Tech CSE,
NIT Surathkal, Karnataka, India.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Finding the min gap in 3 arrays

2011-06-17 Thread Harshal
I think this will work,
have 3 pointers p,q,r pointing last elements of the 3 lists.
compute the difference between each pair.
decrement the index of the list having the min element.
(at each stage, save the current indices and current max distance).

Same logic for the min distance part, just start from index 0.

On Fri, Jun 17, 2011 at 9:43 PM, Ashish Goel  wrote:

> merge two and if required third  array keeping array tag with the elements
> walk over the merged list and see adjacent distance which is minimum with
> the condition that the tage of the adjacent elements are different
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
>
> On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu  wrote:
>
>> U have got 3 sorted arrays A1 A2 and A3 having m n and p elements
>> respectively. A gap of 3 arrays is defined to be max distance between
>> 3 nos if they are put on a no line say u pick three 2 12 and 7 then
>> the gap is 10. Now u have to find an efficient way of chosing 3 nos
>> from these 3 seperate arrays (A1, A2, A3) such that their gap is
>> minimum. Of course if a num say 2 occurs in all 3 then gap is 0!!!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Harshal Choudhary,
III Year B.Tech CSE,
NIT Surathkal, Karnataka, India.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Mutex

2011-06-17 Thread LALIT SHARMA
There is very thin line of difference between semaphore and mutex,,

mutex are like binary semaphore ,,but the are concerned about
execution of any piece of code (critical section) ,where as a
semaphore is program construct which can be used to just hold a lock
on a set of resources .

As said by Ankit ,

thread/process which acquires a lock on mutex , is the only one to unlock it ..

On 6/17/11, ankit sambyal  wrote:
> Yes, even the threads of a single process cannot have access to each
> others mutex.
> Mutexes can be applied only to threads in a single process and do not
> work between processes as do semaphores.
>
>
>
>
>
> On Fri, Jun 17, 2011 at 5:40 AM, Akshata Sharma
>  wrote:
>> When a thread locks a mutex only it can unlock it. Does this implies that
>> even the threads of a single process cannot have access to each others
>> mutex? I mean, if a thread A of process P has acquired a mutex, then only
>> thread A can release it or a thread B of same process P can also release
>> it?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Finding the min gap in 3 arrays

2011-06-17 Thread Ashish Goel
merge two and if required third  array keeping array tag with the elements
walk over the merged list and see adjacent distance which is minimum with
the condition that the tage of the adjacent elements are different


Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652


On Fri, Jun 17, 2011 at 9:36 PM, Dumanshu  wrote:

> U have got 3 sorted arrays A1 A2 and A3 having m n and p elements
> respectively. A gap of 3 arrays is defined to be max distance between
> 3 nos if they are put on a no line say u pick three 2 12 and 7 then
> the gap is 10. Now u have to find an efficient way of chosing 3 nos
> from these 3 seperate arrays (A1, A2, A3) such that their gap is
> minimum. Of course if a num say 2 occurs in all 3 then gap is 0!!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Finding the min gap in 3 arrays

2011-06-17 Thread Dumanshu
U have got 3 sorted arrays A1 A2 and A3 having m n and p elements
respectively. A gap of 3 arrays is defined to be max distance between
3 nos if they are put on a no line say u pick three 2 12 and 7 then
the gap is 10. Now u have to find an efficient way of chosing 3 nos
from these 3 seperate arrays (A1, A2, A3) such that their gap is
minimum. Of course if a num say 2 occurs in all 3 then gap is 0!!!

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Mutex

2011-06-17 Thread ankit sambyal
Yes, even the threads of a single process cannot have access to each
others mutex.
Mutexes can be applied only to threads in a single process and do not
work between processes as do semaphores.





On Fri, Jun 17, 2011 at 5:40 AM, Akshata Sharma
 wrote:
> When a thread locks a mutex only it can unlock it. Does this implies that
> even the threads of a single process cannot have access to each others
> mutex? I mean, if a thread A of process P has acquired a mutex, then only
> thread A can release it or a thread B of same process P can also release it?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Mutex

2011-06-17 Thread Akshata Sharma
When a thread locks a mutex only it can unlock it. Does this implies that
even the threads of a single process cannot have access to each others
mutex? I mean, if a thread A of process P has acquired a mutex, then only
thread A can release it or a thread B of same process P can also release it?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Minimum Rotations

2011-06-17 Thread KK
http://www.spoj.pl/problems/MINMOVE/
This code is showing TLE after some 20th test  case what else can be
optimized???

try:
import psyco
psyco.full()
except ImportError:
pass

string = input()
minlen = string
length = len(string)

string += string[:]
#print(string)

index = 0
for i in range(1, length):
if string[i : i+length] < minlen:
minlen = string[i : i+length]
index = i

print(index)


-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [brain teaser ] Probability Riddle Loaded Revolver 13 june

2011-06-17 Thread varun pahwa
if we rotate again prob. of bullet is 1/3.
and if we pull the trigger then prob of bullet will be 1/4.
so its safe to pull the trigger without rotation.

On Wed, Jun 15, 2011 at 1:30 AM, Anika Jain  wrote:

> henry will give the answer that will favour to save him.. so if rotated
> then probab. of getting safe is 2/3=0.666
> and if not rotated then probab. of getting safe is 3/4=0.75 so its better
> to not to rotate..
>
>
> On Tue, Jun 14, 2011 at 12:36 AM, Arpit Sood  wrote:
>
>> +1 to Kunal's post
>>
>> i think if you rotate again prob. of getting shot is 1/3 and not 1/2
>>
>>
>> On Mon, Jun 13, 2011 at 11:56 PM, sunny agrawal 
>> wrote:
>>
>>> @Douglas
>>> i don't understand your probablity analysis
>>> but still for Rotate again as in your analysis 2/6+1/6 = 1/2
>>> pull the triiger again is still better
>>>
>>> although my thinking was same as kunal explained
>>>
>>>
>>> On Mon, Jun 13, 2011 at 11:20 PM, Douglas Diniz wrote:
>>>
 Six-chambered revolver, so 2 bullets in sequence is the same as 1
 bullet in Five-chambered.
 So, pull the trigger again = 1/5 + 1/5 = 2/5 (to die)
 Rotate again = 2/6 + 1/6 = 1/3 (to die)

 So, is better to rotate again


 On Mon, Jun 13, 2011 at 2:35 PM, Kunal Patil 
 wrote:
 > Assuming everything is unbiased:
 > probability of the next slot to contain a bullet (given, first was
 empty)
 > would be (1/4) = 0.25
 > After spinning:  prob(bullet) = (2/6) = 0.334...
 > We want to minimize the probability...
 > thus answer should be just to pull the trigger again..
 >
 >
 > On Mon, Jun 13, 2011 at 1:40 PM, Piyush Sinha <
 ecstasy.piy...@gmail.com>
 > wrote:
 >>
 >> ignore the above answerit shouldn't rotate again...
 >>
 >> On Mon, Jun 13, 2011 at 1:37 PM, Piyush Sinha <
 ecstasy.piy...@gmail.com>
 >> wrote:
 >>>
 >>> should rotate again..
 >>>
 >>> On Mon, Jun 13, 2011 at 1:12 PM, sunny agrawal <
 sunny816.i...@gmail.com>
 >>> wrote:
 
  Pull the Trigger Again ??
 
  On Mon, Jun 13, 2011 at 1:01 PM, Lavesh Rawat <
 lavesh.ra...@gmail.com>
  wrote:
 >
 > Probability Riddle Loaded Revolver  - 13 June
 >
 > Henry has been caught stealing cattle, and is brought into town
 for
 > justice. The judge is his ex-wife Gretchen, who wants to show him
 some
 > sympathy, but the law clearly calls for two shots to be taken at
 Henry from
 > close range. To make things a little better for Henry, Gretchen
 tells him
 > she will place two bullets into a six-chambered revolver in
 successive
 > order. She will spin the chamber, close it, and take one shot. If
 Henry is
 > still alive, she will then either take another shot, or spin the
 chamber
 > again before shooting.
 >
 > Henry is a bit incredulous that his own ex-wife would carry out
 the
 > punishment, and a bit sad that she was always such a rule
 follower. He
 > steels himself as Gretchen loads the chambers, spins the revolver,
 and pulls
 > the trigger. Whew! It was blank. Then Gretchen asks, 'Do you want
 me to pull
 > the trigger again, or should I spin the chamber a second time
 before pulling
 > the trigger?'
 >
 > What should Henry choose?
 >
 > Update Your Answers at : Click Here
 >
 > Solution:
 > Will be updated after 1 day
 >
 >
 >
 > --
 >
 > "Never explain yourself. Your friends don’t
 need it
 > and your enemies won’t believe it" .
 >
 > --
 > You received this message because you are subscribed to the Google
 > Groups "Algorithm Geeks" group.
 > To post to this group, send email to algogeeks@googlegroups.com.
 > To unsubscribe from this group, send email to
 > algogeeks+unsubscr...@googlegroups.com.
 > For more options, visit this group at
 > http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  Sunny Aggrawal
  B-Tech IV year,CSI
  Indian Institute Of Technology,Roorkee
 
  --
  You received this message because you are subscribed to the Google
  Groups "Algorithm Geeks" group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 >>>
 >>>
 >>>
 >>> --
 >>> Piyush Sinha
 >>> IIIT, Allahabad
 >>> +91-8792136657
 >>> +91-7483122727
 >>> https://www.facebook.com/profile.php?id=10655377926
>>

Re: [algogeeks] Fiddling with Bits

2011-06-17 Thread sunny agrawal
hmm may be because of  [*result will fit into the 64-bit signed integer type
*.]
but i think it can be done optimally
consider if A = 1
B = 7 (taking an easier case)

so for 001,011,101,111  -> 1 = 4*1
for 010,110 -> 10 = 2*2
for 100 -> 100 = 1*4

something like that
so for each A,B we can calculate the final result in the order of no of bits
O(64)


On Fri, Jun 17, 2011 at 3:38 PM, sunny agrawal 
wrote:
>
> but limits of A and B are very large
> 10^15
> how is this possible
> am i missing something,
> like Max(B-A) = 10^6 or 10^7
>
> On Fri, Jun 17, 2011 at 3:30 PM, Arpit Sood  wrote:
>>
>> lol, i mean in linear time
>>
>> On Fri, Jun 17, 2011 at 3:27 PM, sunny agrawal 
wrote:
>>>
>>> where n is ??
>>>
>>> On Fri, Jun 17, 2011 at 3:23 PM, Arpit Sood  wrote:

 i have got AC with O(n)

 On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal 
wrote:
>
> you need to try something better as limits of A and B are very large
:)
> you can not run a loop from A to B
>
> i have not tried it but the logic is there will be many nos which will
give the same value and we dont need to calculate for them all explicitply
:)
>
> On Fri, Jun 17, 2011 at 2:52 PM, KK  wrote:
>>
>> To remove all digits left of the rightmost digit one in the binary
>> representation of some integer what we need to do is this:
>> ans = no & -no
>> and this is what is exactly asked in this problem of SPOJ:
>> www.spoj.pl/problems/MZVRK/
>>
>>
>> #include
>> using namespace std;
>> int main()
>> {
>>unsigned long long int a, b, sum;
>>while(scanf("%lld%lld", &a, &b) != EOF)
>>{
>>  sum = 0;
>>  while(a != (b+1))
>>  {
>>  sum += (a & -a);
>>  a++;
>>  }
>>  printf("%lld\n", sum);
>>}
>>return 0;
>> }
>>
>> Its giving TLE on some 10th case...
>>
>> --
>> You received this message because you are subscribed to the Google
Groups "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
> --
> You received this message because you are subscribed to the Google
Groups "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.



 --
 Regards,
 Arpit Sood

 --
 You received this message because you are subscribed to the Google
Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>>
>>> --
>>> Sunny Aggrawal
>>> B-Tech IV year,CSI
>>> Indian Institute Of Technology,Roorkee
>>>
>>> --
>>> You received this message because you are subscribed to the Google
Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>>
>> --
>> Regards,
>> Arpit Sood
>>
>> --
>> You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>



--
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS

2011-06-17 Thread sukhmeet singh
Can be done by any standard disk scheduling methods.. i guess

On Tue, Jun 14, 2011 at 2:01 PM, Akshata Sharma
wrote:

> Design an elevator system for a 100 story building. Address all issues,
> like number of elevators, speed of each (Not numerically), waiting times
> etc. There would be 100-200 people living/working on each floor. (You don't
> need to discuss the traffic patterns.)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fiddling with Bits

2011-06-17 Thread sunny agrawal
but limits of A and B are very large
10^15
how is this possible
am i missing something,
like Max(B-A) = 10^6 or 10^7

On Fri, Jun 17, 2011 at 3:30 PM, Arpit Sood  wrote:

> lol, i mean in linear time
>
>
> On Fri, Jun 17, 2011 at 3:27 PM, sunny agrawal wrote:
>
>> where n is ??
>>
>> On Fri, Jun 17, 2011 at 3:23 PM, Arpit Sood  wrote:
>>
>>> i have got AC with O(n)
>>>
>>> On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal 
>>> wrote:
>>>
 you need to try something better as limits of A and B are very large :)
 you can not run a loop from A to B

 i have not tried it but the logic is there will be many nos which will
 give the same value and we dont need to calculate for them all explicitply
 :)


 On Fri, Jun 17, 2011 at 2:52 PM, KK  wrote:

> To remove all digits left of the rightmost digit one in the binary
> representation of some integer what we need to do is this:
> ans = no & -no
> and this is what is exactly asked in this problem of SPOJ:
> www.spoj.pl/problems/MZVRK/
>
>
> #include
> using namespace std;
> int main()
> {
>unsigned long long int a, b, sum;
>while(scanf("%lld%lld", &a, &b) != EOF)
>{
>  sum = 0;
>  while(a != (b+1))
>  {
>  sum += (a & -a);
>  a++;
>  }
>  printf("%lld\n", sum);
>}
>return 0;
> }
>
> Its giving TLE on some 10th case...
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee


  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>>
>>> --
>>> Regards,
>>> Arpit Sood
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Sunny Aggrawal
>> B-Tech IV year,CSI
>> Indian Institute Of Technology,Roorkee
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards,
> Arpit Sood
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fiddling with Bits

2011-06-17 Thread Arpit Sood
lol, i mean in linear time

On Fri, Jun 17, 2011 at 3:27 PM, sunny agrawal wrote:

> where n is ??
>
> On Fri, Jun 17, 2011 at 3:23 PM, Arpit Sood  wrote:
>
>> i have got AC with O(n)
>>
>> On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal 
>> wrote:
>>
>>> you need to try something better as limits of A and B are very large :)
>>> you can not run a loop from A to B
>>>
>>> i have not tried it but the logic is there will be many nos which will
>>> give the same value and we dont need to calculate for them all explicitply
>>> :)
>>>
>>>
>>> On Fri, Jun 17, 2011 at 2:52 PM, KK  wrote:
>>>
 To remove all digits left of the rightmost digit one in the binary
 representation of some integer what we need to do is this:
 ans = no & -no
 and this is what is exactly asked in this problem of SPOJ:
 www.spoj.pl/problems/MZVRK/


 #include
 using namespace std;
 int main()
 {
unsigned long long int a, b, sum;
while(scanf("%lld%lld", &a, &b) != EOF)
{
  sum = 0;
  while(a != (b+1))
  {
  sum += (a & -a);
  a++;
  }
  printf("%lld\n", sum);
}
return 0;
 }

 Its giving TLE on some 10th case...

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


>>>
>>>
>>> --
>>> Sunny Aggrawal
>>> B-Tech IV year,CSI
>>> Indian Institute Of Technology,Roorkee
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards,
>> Arpit Sood
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,
Arpit Sood

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fiddling with Bits

2011-06-17 Thread sunny agrawal
where n is ??

On Fri, Jun 17, 2011 at 3:23 PM, Arpit Sood  wrote:

> i have got AC with O(n)
>
> On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal wrote:
>
>> you need to try something better as limits of A and B are very large :)
>> you can not run a loop from A to B
>>
>> i have not tried it but the logic is there will be many nos which will
>> give the same value and we dont need to calculate for them all explicitply
>> :)
>>
>>
>> On Fri, Jun 17, 2011 at 2:52 PM, KK  wrote:
>>
>>> To remove all digits left of the rightmost digit one in the binary
>>> representation of some integer what we need to do is this:
>>> ans = no & -no
>>> and this is what is exactly asked in this problem of SPOJ:
>>> www.spoj.pl/problems/MZVRK/
>>>
>>>
>>> #include
>>> using namespace std;
>>> int main()
>>> {
>>>unsigned long long int a, b, sum;
>>>while(scanf("%lld%lld", &a, &b) != EOF)
>>>{
>>>  sum = 0;
>>>  while(a != (b+1))
>>>  {
>>>  sum += (a & -a);
>>>  a++;
>>>  }
>>>  printf("%lld\n", sum);
>>>}
>>>return 0;
>>> }
>>>
>>> Its giving TLE on some 10th case...
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> Sunny Aggrawal
>> B-Tech IV year,CSI
>> Indian Institute Of Technology,Roorkee
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards,
> Arpit Sood
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fiddling with Bits

2011-06-17 Thread Arpit Sood
i have got AC with O(n)

On Fri, Jun 17, 2011 at 2:59 PM, sunny agrawal wrote:

> you need to try something better as limits of A and B are very large :)
> you can not run a loop from A to B
>
> i have not tried it but the logic is there will be many nos which will give
> the same value and we dont need to calculate for them all explicitply :)
>
>
> On Fri, Jun 17, 2011 at 2:52 PM, KK  wrote:
>
>> To remove all digits left of the rightmost digit one in the binary
>> representation of some integer what we need to do is this:
>> ans = no & -no
>> and this is what is exactly asked in this problem of SPOJ:
>> www.spoj.pl/problems/MZVRK/
>>
>>
>> #include
>> using namespace std;
>> int main()
>> {
>>unsigned long long int a, b, sum;
>>while(scanf("%lld%lld", &a, &b) != EOF)
>>{
>>  sum = 0;
>>  while(a != (b+1))
>>  {
>>  sum += (a & -a);
>>  a++;
>>  }
>>  printf("%lld\n", sum);
>>}
>>return 0;
>> }
>>
>> Its giving TLE on some 10th case...
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,
Arpit Sood

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Tic Tac Toe

2011-06-17 Thread KK
oops !! :) i'll look into that.. thx

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] google interview c testing

2011-06-17 Thread rohit
how to free memory allocated to an array with new function?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fiddling with Bits

2011-06-17 Thread sunny agrawal
you need to try something better as limits of A and B are very large :)
you can not run a loop from A to B

i have not tried it but the logic is there will be many nos which will give
the same value and we dont need to calculate for them all explicitply :)

On Fri, Jun 17, 2011 at 2:52 PM, KK  wrote:

> To remove all digits left of the rightmost digit one in the binary
> representation of some integer what we need to do is this:
> ans = no & -no
> and this is what is exactly asked in this problem of SPOJ:
> www.spoj.pl/problems/MZVRK/
>
>
> #include
> using namespace std;
> int main()
> {
>unsigned long long int a, b, sum;
>while(scanf("%lld%lld", &a, &b) != EOF)
>{
>  sum = 0;
>  while(a != (b+1))
>  {
>  sum += (a & -a);
>  a++;
>  }
>  printf("%lld\n", sum);
>}
>return 0;
> }
>
> Its giving TLE on some 10th case...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Tic Tac Toe

2011-06-17 Thread sunny agrawal
as you can see in this case no of moves of X are 4 and that of O are 3
as X starts first, after both players has played 3 moves each, O would have
already won the game so next move of X is invalid

i got your solution AC after adding this condition :)

On Fri, Jun 17, 2011 at 2:48 PM, KK  wrote:

> @sunny: why the answer for the case u mentioned is no.. those are
> possible set of moves according to me and hence my program outputs
> "yes"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Fiddling with Bits

2011-06-17 Thread KK
To remove all digits left of the rightmost digit one in the binary
representation of some integer what we need to do is this:
ans = no & -no
and this is what is exactly asked in this problem of SPOJ:
www.spoj.pl/problems/MZVRK/


#include
using namespace std;
int main()
{
unsigned long long int a, b, sum;
while(scanf("%lld%lld", &a, &b) != EOF)
{
  sum = 0;
  while(a != (b+1))
  {
  sum += (a & -a);
  a++;
  }
  printf("%lld\n", sum);
}
return 0;
}

Its giving TLE on some 10th case...

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Tic Tac Toe

2011-06-17 Thread KK
@sunny: why the answer for the case u mentioned is no.. those are
possible set of moves according to me and hence my program outputs
"yes"

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Tic Tac Toe

2011-06-17 Thread sunny agrawal
no i didn't mean that
in first test u checking if count of X should be either equal of one more
than that of O

and in last u r checking if both are winning or only only one

but what i meant is if O has already won but no of moves of X are greater
than O the answer should be No but your solution will print yes
Correct me if i m wrong

Test case:

XXO
XXO
..O

Ans: No

tell me what is your output for this case

On Fri, Jun 17, 2011 at 1:56 PM, KK  wrote:

> @sunny:
> This test:
>  if(! ( (countx == counto + 1) || (countx == counto) ) )
>cout << "no" << endl;
> prints no if countx > counto
>
> and this one
>  if(o && x)
> cout << "no" << endl;
>  else
> cout << "yes" << endl;
>
> prints no if both have won or else yes
> correct me if m wrong...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Tic Tac Toe

2011-06-17 Thread KK
@sunny:
This test:
 if(! ( (countx == counto + 1) || (countx == counto) ) )
cout << "no" << endl;
prints no if countx > counto

and this one
 if(o && x)
 cout << "no" << endl;
  else
 cout << "yes" << endl;

prints no if both have won or else yes
correct me if m wrong...

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] [brain teaser ] Friday The 13th Riddle

2011-06-17 Thread Lavesh Rawat
*Friday The 13 Riddle ** **- 17 june *
*
*
*Many people would think Friday the 13th will be an unlucky day. Is it
possible that there is no Friday on 13th through the whole year? How many
Fridays at 13th can we have in a year at most? Can you calculate it out?*
*
* *Update Your Answers at* : Click
Here

Solution:
Will be updated after 1 day


-- 

"Never explain yourself. Your friends don’t need it and
your enemies won’t believe it" .

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.