oh, nevermind, sorry ;P you want the 1's at the beginning, not the end...
//friday
On Friday, April 22, 2016 at 4:07:53 PM UTC-4, icy` wrote:
>
> Hi,
> I'm not sure I understand the second example. Shouldn't the second one
> also produce an answer of 1 (swap the on
Hi,
I'm not sure I understand the second example. Shouldn't the second one
also produce an answer of 1 (swap the one in index 1 with the zero in the
last index)
0 *1* 0 1 1 1 *0*
icy`
On Tuesday, March 29, 2016 at 10:00:21 AM UTC-4, Régis Bacra wrote:
>
> This puzzle come
array are slowly built in this way. Ruby helps
deal with some of the other minor issues. Pic below.
icy`
[image: Inline image 1]
--
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
By missing I assume that the numbers are consecutive and we are at
least provided with a range.
Suppose for the sake of example, the range is 100,000 to 400,000 with
203,148 being the missing number. They come to us shuffled up, and let us
suppose we are taking them from the hard drive instead
nice solution, Dave!
@Umer -- if the sought ele is first, then Dave's code has it sitting in the
variable temp for a little while. Loop will stop when size is 0, since
arr[0]==elem. Now he throws temp back into arr[0], which will return index
0 from the last compare line.
On Wednesday,
why not just brute force this? one little array contains [a, (a+d),
(a+2d), (a+3d), (a+4d) ], which is then filtered so that none of those are
multiples of another.
Then set a count variable to m-n+1. Check all numbers in range against
your little array, decrementing count and breaking out if a
would then guess 66, 68, 70, and 86)
icy`
On Feb 28, 7:44 am, srikanth reddy malipatel srikk...@gmail.com
wrote:
{39,41,43,45} incremented by 2
{49,51,53,55} incremented by 2
{64,?,?,?}
first number in each set is considered as base number.
3 is for the number of numbers in each set
I dont know Pascal too well, but to me it looks like nested if
statements.
If xy , all the rest of it happens
Since x is not greater than y, nothing happens. So x and y should
remain the same (10,20)
On Nov 17, 6:09 am, Vijay Khandar vijaykhand...@gmail.com wrote:
In the following Pascal
yea, i'd go with greedy also. Fill bin with biggest size s1 as much
as possible (and same for other bins), then try to squeeze in next
biggest size s2, etc.
On Oct 29, 7:17 am, teja bala pawanjalsa.t...@gmail.com wrote:
Greedy knapsack algorithm will work fine in this case as in each bin
you didnt mention if duplicate elements should appear in the
intersection or not. If no duplicates necessary, then your language
may already have intersection between arrays built in. Or you should
write an intersection operator/method between arrays (in ruby it is
just the operator). My
sorry, i made a slight coding mistake in my last post (invisible 7th
array) , but the logic remains the same...corrected sample output:
arrays: 6
elements in each array: 20
range: 1 to 5
array #1: [3, 4, 3, 4, 5, 3, 2, 2, 1, 4, 2, 3, 4, 4, 3, 1, 3, 2, 4, 4]
array #2: [1, 4, 5, 2, 1, 5, 1, 4, 3,
small typo.. in part 2) it should say 13-(1+4+6)=2. Basically
when the position becomes smaller than the element, you stop subtracting.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
is this contest still going? if so, where ? i have a solution that
does
(100, 1267650600228229401496703205376 )(just one hundred 1's)
in 0.03 seconds in an older ruby on an older pc
I'd like to submit ;P
On Oct 21, 10:48 pm, sunny agrawal sunny816.i...@gmail.com wrote:
yea i know 1st
one possible ruby solution/pic attached
--
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.
one possible solution in ruby (sry if this is double-posted -- i did not
see it come up the first time)
[image: digsum_output.png]
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
compact the string (remove all null
bytes, or turn all extra spaces into one space, etc).
icy`
On Oct 10, 3:08 pm, sunny agrawal sunny816.i...@gmail.com wrote:
Trie will take too much space..
Balanced Binary tree can be Better ...??
On Tue, Oct 11, 2011 at 12:16 AM, Ankur Garg ankurga
Just use a hash to count frequency of something; e.g. in ruby:
ar= %w(a a b c a b b c d e a d e f)
freq=Hash.new(0)
ar.each {|c| freq[c]+=1}
p freq
#output
#{a=4, b=3, c=2, d=2, e=2, f=1}
you could only do it in place in O(1) only if your input array is
already 2*(number of all possible
]
benchmark output:
[image: max_subarray_output.png]
To test this, I had shuffled an array of size 1000 with k=25.I also
called each method 1000 times, which shows 5x improvement over naive method
icy`
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
I apologize to the group; i meant to post as reply to Find the Max
from each sub-array of size k but I accidentally selected the word
Options as well. Sorry.
On Sep 2, 3:42 pm, icy` vipe...@gmail.com wrote:
comparison/benchmarks of the
1) naive method, which just calls max with every new
with the algorithm to place the rooks on the board, 8!
permutations, one on each row, and then check all diagonals. This can
be limited to even fewer iterations, but it was fast enough for me.
hope this helps,
icy`
On Sep 1, 3:30 pm, mc2 verma qlearn...@gmail.com wrote:
hey guys ,
I am trying to solve 8-queens
actually this makes me think about the question requirements a bit..
in math, arent sets supposed to have *unique* elements?
so if A= [ 1 2 3 4] , B= [ 1 2 3 4], then shouldnt
S = { (4,4) (4,3) (4,2) (4,1) (3,3) (3,2) (3,1) (2,2) (2,1)
(1,1) } ??
since A is equal to B, the size of S is
i kinda just ate my own words there ;P if a set has unique
elements, {4,4} isnt possible.. it would just be {4}
i'm not sure how to deal with ( ) instead of { }
On Sep 1, 5:12 pm, icy` vipe...@gmail.com wrote:
actually this makes me think about the question requirements a bit..
in math
duplicates as you
are iterating through A, B
On Sep 1, 5:50 pm, Dave dave_and_da...@juno.com wrote:
@Icy: You left off the pairs (3,4), (2,4), (2,3), (1,4), (1,3), and
(1,2). These are different than the pairs you listed, because they are
ordered: the first element is from set A and the second
Dave has a nice idea but I cant get it to work =/
[[1, 0, 0, 1], [0, 0, 1, 0], [0, 0, 0, 0]] original matrix
[[1, 0, 1, 1], [1, 1, 1, 1], [0, 0, 1, 1]] dave's
[[1, 1, 1, 1], [1, 1, 1, 1], [1, 0, 1, 1]] expected
Maybe I converted it wrong. My method was basically the same as
Anup's --
1st
1. b2. c 3. a
I think ;P I tried to do all by hand with some shortcuts, but i got 2
for the third one, so it' s a bit of a guess
On Aug 30, 10:27 am, abhishek abhishek.ma...@gmail.com wrote:
1. Teacher asked the students to find the cube root of a natural
number but she did not mention
For the third one by hand, I was just trying to keep track of 1-2 of
the first digits for each section.
I broke into sections as follows (^ to mean power here):
9! = (I just did this by hand, 1728x210=362880) , so we take 36.
10! to 19! = approx 1^10 = 1
20! to 29! = approx 2^10 = 1024 = 10
well if the answer is more than 3, I would be surprised. There are
probably some integer rules to justify really small limits, but here
is how I justified it to myself:
I. Treat every variable like it is a.2a^2 = 4a , or a^2 =
2a . This only works for a=1, a=2. So likely a cannot
Yea, I hope the intermediate words are dictionary words; it's more
fun that way. I played such a game before, where you and a friend
try to convert some 4-letter word into another, using legal words.
BIKE - LAZY
BIKE
BAKE
RAKE
RAZE
LAZE
LAZY
On Aug 30, 2:25 am, kARTHIK R k4rth...@gmail.com
shows this in case #1 and case #4).
I think the formula does not cut enough of these intersections off.
I'm getting 962 for n=6 , so lol
icy`
On Aug 26, 10:34 am, Naren s sweetna...@gmail.com wrote:
varun: can u explain it little further..
On Wed, Aug 10, 2011 at 7:49 PM, varun pahwa
Other than making little loops and risking the fall on the first trip
down, I dont think the rope question has an answer. NVIDIA just
wanted to see if you were suicidal =D
On Aug 26, 3:36 pm, Piyush Grover piyush4u.iit...@gmail.com wrote:
Cut the rope in 50mtrs and 100mtrs length.
Make a
my binary search method in Ruby is similar to Don's. I tested with
array [1,1,2,2,2,2,3,3,9,14,14] , to which the answer should be 9,
and now added what I call fluff (meaningless numbers) to either:
the left (300_000 zeroes at the head) , making it difficult for direct
approach; the middle
not enough information, imo. Tell me more about the given string...
is the string made up of consecutive integers/characters ? Are there
always the same number of each character type? And the goal is to
braid , like the hairstyle, as much as possible (if the previous
answer is no, all braids
isnt this logarithmic?regular loop 1..n runs in n/(1 step each
time) - O(n)
this loop n/(k + k^2 each time) - ln(n)/ ( ln(k) + k ln(2) ) -
ln(n-k) - O(ln(n)) or something like that ;P I was going from
memory. Please confirm, but I feel like it approaches logarithmic
speed.
On
nice prakash. Algorithm is definitely better than brute force. But
here is brute force anyway, just go from 2 to square root of n ;P
I initially misread it and thought you were asking for ANY {c,d} set
in which c,d are factors of n (but not necessarily c*d = n) . That
wouldve been all of
brute force...http://codepad.org/D07BNo91 There are some
checks to help reduce O(n^2), so I want to say.. O(1.5n) ?=)
#output for str = 'abaccddccefe'
#ccddcc 6
#for str = 'abraxyzarba'
#a 1
On Aug 22, 1:09 pm, uma umai...@gmail.com wrote:
can yo tell exactly , how the suffix
sorry, I meant to joke about (0.5 * n^2) ;P
On Aug 22, 4:46 pm, icy` vipe...@gmail.com wrote:
brute force... http://codepad.org/D07BNo91 There are some
checks to help reduce O(n^2), so I want to say.. O(1.5n) ? =)
#output for str = 'abaccddccefe'
#ccddcc 6
#for str
with the 5min, the trip time
is 5min.
*if a person falls off the bridge, he/she goes to /dev/null;P
So what is the fastest way for everyone to cross the bridge, and how
long does that take?
~icy
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group
hmm... interesting logic, but what about, for example, 8 people and
3 hats. Why can't one of the five without hats also be unsure and
try to go swimming on one of the nights?
I was thinking, if they somehow know how many hats there are (writing
numbers in the sand or other cheating methods),
Well no, I would think it would match Balls for him, since it is
greedy -- it would try to match as much as possible that works/is in
dict. So I have to agree with Aditya here, but I would go from the
back/right to the left. So I would first get round, then hopefully
are round and finally
#!/usr/bin/ruby -w
#array of unsorted positive integers
# find the [only] one that is duplicated
arr= [97,2,54,26,67,12,1,19,44,4,29,36,67,14,93,22,39,89]
h = Hash.new(0)
arr.each {|n|
h[n]+=1
(puts n; break) if h[n]==2
}
#output
#67
I hope this meets the requirements ;P
On
40 matches
Mail list logo