help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: math problem: 28, 39, and 55 days


From: Emanuel Berg
Subject: Re: math problem: 28, 39, and 55 days
Date: Fri, 19 Jan 2018 03:26:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

darrellhicks450 wrote:

>> The first Survivor ever, in Sweden, was only
>> 28 days. (Later it was extended to 40.)
>> 
>> Today's US Survivor is 39.
>> 
>> Australian S04 was 55!
>> 
>> If we define the difficulty of surviving day
>> x as a function of the number of days
>> preceeding it, i.e.
>> 
>>    1, 2 ... (x - 1)
>> 
>> then how much more difficult is it to
>> survive/complete Australian Survivor than
>> the US version, and the original
>> Swedish version?
>
> 55 days is approximately 40% longer than
> 39 days.
>
> I would estimate difficulty exceeds 40%‼️
>
> 55 days is 💯% longer than 28 days IOW A LOT
> HARDER‼️

Intuition: pass
Math: fail

:)

I redefined the problem just a bit so that at
day x, that day will also count, i.e. +x, as
otherwise, day 1 will have a zero cost.

Anyway here (last in the post) is some
Lisp (Elisp) to do the computation. The answer,
if the software is correct, is:

;; Australia vs USA:     197%
;; Australia vs Sweden:  379%

That is, the AU version is almost twice as
difficult as the US one, which corresponds to
my intuition as well.

(require 'cl-lib)

;; naive first attempt
;; (that does work)

(defun cost-at-day-loop (day)
  (let ((cost 0)
        (n    0) )
    (cl-loop for n from 0 upto day do
      (cl-incf cost n) )
    cost) )

;; example: 5 -> (+ 1 2 3 4 5) = 15

;; testing:
;; (cost-at-day-loop 5) ; 15
;; (cost-at-day-loop 1) ;  1
;; (cost-at-day-loop 0) ;  0

;; better second attempt

(defun cost-at-day (day)
  (apply #'+ (number-sequence 1 day)) )

;; testing:
;; (cost-at-day 5) ; 15
;; (cost-at-day 1) ;  1
;; (cost-at-day 0) ;  0

;; compute difficulty
(defun compare-difficulty ()
  (let*((au (cost-at-day 55))   ; 1540
        (us (cost-at-day 39))   ;  780
        (se (cost-at-day 28))   ;  406
        (au-vs-us (* (/ au (* us 1.0)) 100))
        (au-vs-se (* (/ au (* se 1.0)) 100))
        (au-vs-us-str (format "\n\n;; Australia vs USA:     %.0f%%\n" au-vs-us))
        (au-vs-se-str (format     ";; Australia vs Sweden:  %.0f%%\n" 
au-vs-se)) )
    (insert au-vs-us-str)
    (insert au-vs-se-str) ))

;; (compare-difficulty)

;; Australia vs USA:     197%
;; Australia vs Sweden:  379%

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]