Re: Lua scripting challenge

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Lua scripting challenge

szbnwer@gmail.com
hi there! :)

i hope that basically u wrote the same :D

local getAvgWorkerTime=function(log)
  local unpack=unpack or table.unpack
  local sum, count=0, 0
  local workers={}
  for l in io.lines(log) do
    -- hour min sec msec worker message
    local h, m, s, ms, w, msg=l:match'^(%d%d):(%d%d):(%d%d)%.(%d%d%d)
worker%-(%d+).- %- (.*)$'
    -- 1: start; 2: end
    local state=msg and (msg:match'money transfer' and 1 or
msg:match'Transfer to' and 2)
    if state then
      w=tonumber(w)
      local t=tonumber(h)*60*60*1000 + tonumber(m)*60*1000 +
tonumber(s)*1000 + tonumber(ms)
      if state==1 then -- start
        workers[w]=t
      else -- end
        local dt -- delta/diff (as you like it)
        dt=t-workers[w] -- previous
        dt=0<=dt and dt or 60*60*1000-dt -- past midnight
        count=count+1
        sum=sum+dt
        workers[w]=nil end end end -- cleanup, not really necessary
  return math.floor(sum/count).. ' milliseconds' end

Out(getAvgWorkerTime'./tmp/hard.log')


otherwise, where is the challenge?

bests! :)

Reply | Threaded
Open this post in threaded view
|

Re: Lua scripting challenge

szbnwer@gmail.com
(there is a stolen space in the long pattern before "worker", where
gmail broke it, but the other two line breaks are straightforward)

Reply | Threaded
Open this post in threaded view
|

Re: Lua scripting challenge

Tim Hill
In reply to this post by szbnwer@gmail.com


> On Jun 20, 2019, at 11:58 AM, sean570 <[hidden email]> wrote:
>
> Background story:
>
> Our customer is running a financial "real-time audit" service. This includes
> a micro-service that audits money transfers. Naturally the service also
> writes to ​a log file​.
>
> We were asked to monitor the performance of the "money transfer auditing"
> micro-service. To do this we need to be able to calculate ​the average time
> it takes to audit a money transfer​.
>
> Your task:
>
...

“Challenge” = “Please write our app for us for free” ?

—Tim


Reply | Threaded
Open this post in threaded view
|

Re: Lua scripting challenge

Francisco Olarte
Tim:

On Sat, Jun 22, 2019 at 5:26 AM Tim Hill <[hidden email]> wrote:
 ...
> “Challenge” = “Please write our app for us for free” ?

Don't be cruel. Given the level of specification, lack of details and
unpractical formats it can at most be a "please do my homework".

Francisco Olarte.

Reply | Threaded
Open this post in threaded view
|

Re: Lua scripting challenge

Jim-2
In reply to this post by Tim Hill
On Jun 20, 2019, at 11:58 AM, sean570 <[hidden email]> wrote:
>>  Our customer is running a financial "real-time audit" service. This includes
>>  a micro-service that audits money transfers. Naturally the service also
>>  writes to ​a log file​.

kewl, sounds really interesting.

>>  We were asked to monitor the performance of the "money transfer auditing"
>>  micro-service. To do this we need to be able to calculate ​the average time
>>  it takes to audit a money transfer​.

sounds like a really hard one, good luck.

"micro-service" ?
try using more buzzwords next time, sounds more impressive and hence
could turn out to be more persuasive.

>>  Your task:

no, not our task.

> “Challenge” = “Please write our app for us for free” ?

sounds so indeed, could you please do my (home ?) work,
i can't solve it, so just post it to the Lua mailing list, let's see
if some idiot will do my work.


Reply | Threaded
Open this post in threaded view
|

Re: Lua scripting challenge

szbnwer@gmail.com
hi guys! :)


ill be a bit rude here, but no offense, i dont wanna hurt no one, so
dont take any of it seriously, just only look behind my words!!

Tim Hill:
>  “Challenge” = “Please write our app for us for free” ?
most likely, but who knows?! sean570 havent confirm that...

Jim:
> let's see if some idiot will do my work.
thx bruh, thats me, and im proud about doing so, and not cuz the level
of the callenge...

> i can't solve it, so just post it to the Lua mailing list
sounds like a reason to help him. :) just cuz y not? cuz he is a human
being, im just as well, i could also get some minor free time to help,
and in general, i like to do so. (and to give back to the communities
as well.) cuz thats a measurement to me to being human humanely...
`assert(self.gracious~=self.idiot)`


u guys r wrecking my experiment :'( i was curious about the outcome of
doing the opposite of the obvious that leads nowhere. while putting on
the forum police hat feels like being superior, i think it just isnt
kawl, nor superior. or just do it kindly, and give some advice for the
future.

otherwise i had a reasonable question a few days ago, and i got only a
single answer for the misinterpretation of my actual question (but i
appreciated the nice intention!!) so ive thought that i can save an
innocent stranger from the same feeling. but sure, lua is opensauce,
so just (((hell fkn))) y anyone ask anything at all?!! those bastards
dont even pay for it!

while u guys r trying to teach ppl to behave The Right Way™ related to
forums, i do the same for being a human being. most likely he just
took the wrong words, maybe in the hope that he will get one more
answer than none, but he wasnt rude with anyone, and also, it just
cant be expected from everyone to live in the cyberspace and act the
same way as the native cyberkids would do it by following the
unwritten code... a good advice for u guys is to ignore things when u
foresee that u wouldnt b kind and constructive, and plzzz, just play
kind with each others! :)


i wish all the bests to all of u! like really!! :)

Reply | Threaded
Open this post in threaded view
|

Re: Lua scripting challenge

Tim Hill


> On Jun 23, 2019, at 9:29 AM, [hidden email] wrote:
>
> hi guys! :)
>
> while u guys r trying to teach ppl to behave The Right Way™ related to
> forums, i do the same for being a human being. most likely he just
> took the wrong words, maybe in the hope that he will get one more
> answer than none, but he wasnt rude with anyone, and also, it just
> cant be expected from everyone to live in the cyberspace and act the
> same way as the native cyberkids would do it by following the
> unwritten code... a good advice for u guys is to ignore things when u
> foresee that u wouldnt b kind and constructive, and plzzz, just play
> kind with each others! :)
>
>
> i wish all the bests to all of u! like really!! :)
>

First, I put a question mark at the end of my remark, which should have made it clear I was *speculating* that the post was not all it appeared to be. However, regardless of etiquette, “The Right Way” it seems to me is to be HONEST. It seems unlikely to me that the poster was truly issuing a programming challenge, and that there appeared to be some ulterior motive (homework, interview question .. who knows?) for the post.

I’m more than happy to help someone who says “I have a tricky assignment…” etc, and have done so many many times. But I’m not happy about someone who uses subterfuge. I dont KNOW it was subterfuge, but it certainly LOOKED like it, hence my speculative post. If the OP wishes to state that is WAS a challenge and I was mistaken I will be happy to apologize. But for now I stand by my original post.

—Tim




Reply | Threaded
Open this post in threaded view
|

Re: Lua scripting challenge

szbnwer@gmail.com
Tim Hill:
thats fine, u were legit!!! actually i intended to address most of my
words to Jim. so thats my mistake that i was clearly unclear about
that here and there! :D sorry for accidentally messing with your mood!
:)