that's floating point for you.
http://en.wikipedia.org/wiki/Floating_point
--
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/-/RcduUpABmi8J.
To post to this
EkoPath compiler has been open sourced
recently: http://www.pathscale.com/ekopath-compiler-suite
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
without indexes in erlang:
reverse(String) -
reverse(String, []).
reverse([], NewString) -
NewString;
reverse([Head|Rest], NewString) -
reverse(Rest, [Head|NewString]).
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this
here's efficient oneliner without any string manipulation
divide every number by 10^(log10(x).ceil)
sort
convert back to original numbers
join array into string
there are edge-cases where this doesn't work but they can be dealt with
easily - have to go back to work :)
--
You received this
wont work for this tree:
x
/\
x x
/\
x x
/ \
xy
/ \
xx
/
simplest algo: find a node with max depth M and go up tree calculating max
depth of all upper branches that do not contain M until reaching root node
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
some explanation
say we have numbers 2 3 5 78
divide all by something to get 0.2, 0.3, 0.5, 0.78
simple sort will give you 0.78, 0.5, 0.3, 0.2
multiply all numbers to get original ones 78 5 3 2
join 78532
--
You received this message because you are subscribed to the Google Groups
Algorithm
possible fix for 100 10 edgecases would be to simply array.map{|x| x*10+1}
and then get rid of that after sorting
--
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
@Sunny i explained how to deal with edgecases right after my post
1, 101 - 11, 1011
11, 1011 - 0.11, 0.1011
sort - 0.11, 0.1011
restore - 1, 101
join - 1101
i can't think of any fail examples anymore
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
@halo check my previous messages
we multiply every element by 10 and add 1
90, 9 - 901, 91
901, 91 - 0.901, 0.91
sort - 0.91, 0.901
revert - 9, 90
join - 990
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
so here's oneliner code in ruby:
a.map{|x| x=x*10+1; -x/10.0**Math.log10(x).ceil}.sort.map{|x|
(-x).to_s[2..-2]}.join
--
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
11 matches
Mail list logo