<commit_before>local computer = require("computer")
local event = require("event")

local function trunc(num, numDecimalPlaces)
  local mult = 10^(numDecimalPlaces or 0)
  return math.floor(num * mult) / mult
end

local function needsCharging(threshold, distanceFromCharger)
  distanceFromCharger = distanceFromCharger or 0
  local percentCharge = (computer.energy() / computer.maxEnergy())
  -- require additional 1% charge per 25 blocks distance to charger
  if (percentCharge - ((distanceFromCharger / 25) / 100)) <= threshold then
    return true
  end
  return false
end

local function waitUntilCharge(threshold, maxWaitSeconds)
  maxWaitSeconds = maxWaitSeconds or 300
  while maxWaitSeconds > 0 do
    local percentCharge = (computer.energy() / computer.maxEnergy())
    if (percentCharge >= threshold) then
      return true
    end
    maxWaitSeconds = maxWaitSeconds - 1
    event.pull(1, "_chargewait")
  end
  local percentCharge = (computer.energy() / computer.maxEnergy())
  return percentCharge >= threshold
end

return {
  trunc = trunc,
  needsCharging = needsCharging,
  waitUntilCharge = waitUntilCharge<commit_msg>lame debugging<commit_after>local computer = require("computer")
local event = require("event")

local function trunc(num, numDecimalPlaces)
  local mult = 10^(numDecimalPlaces or 0)
  return math.floor(num * mult) / mult
end

local function needsCharging(threshold, distanceFromCharger)
  distanceFromCharger = distanceFromCharger or 0
  local percentCharge = (computer.energy() / computer.maxEnergy())
  -- require additional 1% charge per 25 blocks distance to charger
  print(percentCharge)
  print((distanceFromCharger / 25) / 100)
  print(threshold)
  if (percentCharge - ((distanceFromCharger / 25) / 100)) <= threshold then
    return true
  end
  return false
end

local function waitUntilCharge(threshold, maxWaitSeconds)
  maxWaitSeconds = maxWaitSeconds or 300
  while maxWaitSeconds > 0 do
    local percentCharge = (computer.energy() / computer.maxEnergy())
    if (percentCharge >= threshold) then
      return true
    end
    maxWaitSeconds = maxWaitSeconds - 1
    event.pull(1, "_chargewait")
  end
  local percentCharge = (computer.energy() / computer.maxEnergy())
  return percentCharge >= threshold
end

return {
  trunc = trunc,
  needsCharging = needsCharging,
  waitUntilCharge = waitUntilCharge
{'fraction_non_alphanumeric': 0.08747346072186836, 'fraction_numerical': 0.01740976645435244, 'mean_word_length': 4.416091954022988, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2286845', 'n_tokens_mistral': 736, 'n_tokens_neox': 670, 'n_words': 203}