HackerTrans
TopNewTrendsCommentsPastAskShowJobs

escanor

no profile record

comments

escanor
·20 gün önce·discuss
brilliant!
escanor
·21 gün önce·discuss
it is:

  (async function(oracle, punch, delay) {
    async function sleep(ms) {
      return new Promise((resolve, _) => {
        setTimeout(resolve, ms)
      })
    }
    
    for (let i = 0; i < 100; i++) {
      const state = oracle._state
      const block = oracle.predictNextPunch()
      oracle._state = state
      
      punch(block === 'L' ? 'R' : 'L')
      
      await sleep(delay)
    }
  })(oracle, punch, 150)
escanor
·21 gün önce·discuss
pure random player:

  (async function(punch, delay) {
    async function sleep(ms) {
      return new Promise((resolve, _) => {
        setTimeout(resolve, ms)
      })
    }
    
    for (let i = 0; i < 100; i++) {
      punch(['L', 'R'][(Math.random() * 2) | 0])
      await sleep(delay)
    }
  })(punch, 150)
  
"cheating" player:

  (async function(oracle, punch, delay) {
    async function sleep(ms) {
      return new Promise((resolve, _) => {
        setTimeout(resolve, ms)
      })
    }
    
    for (let i = 0; i < 100; i++) {
      punch((i + 1) < oracle.minForPrediction ? ['L', 'R'][(Math.random() * 2) | 0] : oracle.predictNextPunch() === 'L' ? 'R' : 'L')
      
      await sleep(delay)
    }
  })(oracle, punch, 150)

is it possible to do any better? i haven't fully read frog/oracle code
escanor
·3 yıl önce·discuss
Who does that algorithm really serve?
escanor
·4 yıl önce·discuss
great work! just a note regarding tf-idf, when you mention log10: i think you're missing the point on the reason of log and most importantly base 10. namely, using log10 gives us a perspective on the number of digits of the term/document frequency. if a term "A" occurs 23 times and a term "B" occurs 50, they will have a very close representation (because both numbers are 2 digits ones).

anyway, thanks for the submission
escanor
·5 yıl önce·discuss
> for index, item in enumerate(menu):

should be

> for index, item in enumerate(menu, start=1):

for the example to be correct :)