1
\$\begingroup\$

Your program will be run an undetermined amount of times. On all but the last, there will be a file called data in the same directory of your program that has the same value each time. On the last run, the file will be there but will have different data in it. On all the times except the last, you can do whatever you want, as long as the following rules are met:

  • Don't output anything
  • Don't change data file

On the last run, you must print out the diff of the first data file and the current data file.

Rules:

  • You may save whatever you want in any files you want, just don't edit the data file

Scoring:

  • Lowest char score wins

Cheating encouraged. You have no indication of which run you're in except that the data file is changed.

\$\endgroup\$
8
  • \$\begingroup\$ what's the definition of "diff"? \$\endgroup\$
    – Doorknob
    Dec 23, 2013 at 2:36
  • 1
    \$\begingroup\$ also, what is the possible contents of data? Can we assume it contains all alphanumeric characters? \$\endgroup\$
    – Doorknob
    Dec 23, 2013 at 2:38
  • \$\begingroup\$ @DoorknobofSnow en.wikipedia.org/wiki/Diff \$\endgroup\$
    – Iszi
    Dec 23, 2013 at 3:13
  • 1
    \$\begingroup\$ what I meant is, can we do something like -olddata +newdata? what is the format of the diff? \$\endgroup\$
    – Doorknob
    Dec 23, 2013 at 3:13
  • 1
    \$\begingroup\$ On all the times except the last, we don't output anything. How is the "last run" defined? \$\endgroup\$
    – KGo
    Dec 23, 2013 at 7:39

2 Answers 2

6
\$\begingroup\$

Bash (31)

[ -e x ]&&diff data x;cp data x

Kinda obvious.

\$\endgroup\$
0
\$\begingroup\$

Here it is with good ol' Windows batch:

@echo off
  if exist lastdata goto compare_data
  type data > lastdata 
  goto end
:compare_data
  fc data lastdata > nul
  if errorlevel 1 goto last
  if errorlevel 0 goto end
:last
  fc data lastdata
  del lastdata
:end
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.