18
\$\begingroup\$

Introduction

On March 24th, 2015 @isaacg golfed his Pyth answer from 44 to 42 bytes. Since a crossed out 44 (44) looks a lot like a regular 44, @Optimizer made the following comment:

striked out 44 is still normal 44 :(

After that, on October 21st, 2015, @Doorknob♦ golfed his Ruby answer from 44 to 40 (and later 38) bytes and added the following part to his answer, with a link to that original comment of @Optimizer:

crossed out 44 is still regular 44 ;(

This was the start of an answer-chaining meme, where every crossed out 44 (and in some occasions 4 or 444) linked back to the previous one.

Then on April 8th, 2017 (I'm not sure if this was the first answer to do so, but it's the earliest one I could find), @JonathanAllan golfed his Python answer from 44 to 39. He however used <s>&nbsp;44&nbsp;</s> so the 44 would look like this:  44 , and added the following to his answer:

Crossed out &nbsp;44&nbsp; is no longer 44 :)

And that was basically the (beginning of the) end of the meme.

Challenge

As for this challenge: Given a list of positive integers and a date, output the list comma-and-space separated where every number except for the last one is placed between <s>...</s> tags.

In addition, if any of the crossed out numbers is in the sequence [4, 44, 444, 4444, ...] (A00278 on oeis.org):

  • If the date is before April 8th, 2017: Also output the exact (all lowercase and with semicolon emoticon) text crossed out N is still regular N ;( (N being the crossed out number from the sequence) on a second line.
  • If the date is April 8th, 2017 or later: The crossed out number N from the sequence should have the leading and trailing &nbsp; added. No need for any additional lines of output.

Examples:

Input: list = [50, 48, 44, 41], date = January 1st, 2017
Output:

<s>50</s>, <s>48</s>, <s>44</s>, 41
crossed out 44 is still regular 44 ;(

Input: list = [500, 475, 444, 301, 248], date = June 2nd, 2018
Output:

<s>500</s>, <s>475</s>, <s>&nbsp;444&nbsp;</s>, <s>301</s>, 248

Challenge rules:

  • You can assume the input-list is a sorted list from largest to smallest, only containing positive integers. In reality a byte-count can also go up due to bug-fixes, but for the sake of this challenge we pretend it only goes down.
  • You can assume only a single number from the sequence [4, 44, 444, 4444, ...] is present in the input-list (if any).
  • The output format is either printed to STDOUT, or returned as a string (or character array/list/2D-array if that's preferable). A trailing newline is of course optional.
  • The output format is strict. <s>...</s> is mandatory; &nbsp;...&nbsp; is mandatory; ", " (comma and space) is mandatory; and \ncrossed out ... is still regular ... ;( exactly is mandatory (on a separated line).
  • You may take the input-date as date-objects; timestamps; loose integers for year, month, and day; a single number in the format yyyyMMdd; integer days since December 31st, 1899 (which would be 42832 for April 8th, 2017); or any other reasonable input-format. The date if-statement isn't the major part of this challenge.
  • The input integer-list can also be a list of strings if you want.
  • You don't have to add the <sup>...</sup> tags to the crossed out ... is still regular ... ;( line as is usually done with the actual meme answers.
  • You can assume the input-list will never contain byte-counts outside the [1, 50000] range (so you'll only have these five {4, 44, 444, 4444, 44444} to worry about).

General rules:

  • This is , so shortest answer in bytes wins.
    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
  • Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
  • Default Loopholes are forbidden.
  • If possible, please add a link with a test for your code.
  • Also, adding an explanation for your answer is highly recommended.

Test cases:

Input: [50, 48, 44, 41] and January 1st, 2017 
Output:
<s>50</s>, <s>48</s>, <s>44</s>, 41
crossed out 44 is still regular 44 ;(

Input: [500, 475, 444, 301, 248] and  June 2nd, 2018
Output:
<s>500</s>, <s>475</s>, <s>&nbsp;444&nbsp;</s>, <s>301</s>, 248

Input: [8, 6, 4] and December 5th, 2017
Output:
<s>8</s>, <s>6</s>, 4

Input: [8, 6, 4, 3, 2] and September 15th, 2015
Output:
<s>8</s>, <s>6</s>, <s>4</s>, <s>3</s>, 2
crossed out 4 is still regular 4 ;(

Input: [119, 99, 84, 82, 74, 60, 51, 44, 36, 34] and February 29th, 2016
Output:
<s>119</s>, <s>99</s>, <s>84</s>, <s>82</s>, <s>74</s>, <s>60</s>, <s>51</s>, <s>44</s>, <s>36</s>, 34
crossed out 44 is still regular 44 ;(

Input: [404, 123, 44] and March 4th, 2016
Output:
<s>404</s>, <s>123</s>, 44

Input: [4, 3] and April 8th, 2017
Output:
<s>&nbsp;4&nbsp;</s>, 3

Input: [44] and October 22nd, 2017
Output:
44

Input: [50000, 44444, 1500] and August 1st, 2018
Output:
<s>50000</s>, <s>&nbsp;44444&nbsp;</s>, 1500

Input: 50, 38, 23 and September 8th, 2001
Output:
<s>50</s>, <s>38</s>, 23
\$\endgroup\$
  • \$\begingroup\$ Your last test case is missing its date? \$\endgroup\$ – Neil Aug 8 '18 at 8:47
  • 1
    \$\begingroup\$ @Neil Ah oops.. Fixed. Date doesn't really matter for that one, but added one regardless. Thanks for noticing. \$\endgroup\$ – Kevin Cruijssen Aug 8 '18 at 8:49
  • 1
    \$\begingroup\$ I can confirm that I had not noticed anyone use the non-breaking space for this specific purpose and that was why I wrote the "no longer" text. \$\endgroup\$ – Jonathan Allan Aug 8 '18 at 9:16
  • \$\begingroup\$ (I can also confirm that I had used it prior to using it with 44 - I believe that is when I first used them) \$\endgroup\$ – Jonathan Allan Aug 8 '18 at 9:35
  • \$\begingroup\$ As we can take input as days since 1889-12-31, can we also take days since 2017-04-08? \$\endgroup\$ – TFeld Aug 8 '18 at 11:49
5
\$\begingroup\$

Jelly,  444 , 94, 93 bytes

Ñȧ$“&nbsp;”,¤j$€io.ɗ¦@Ṗj@€“<s>“</s>”oj⁾, 
⁴>⁽A€
“¢⁻$gẆẠ⁷Ṭ]ḳṁṛż?=çỊI×V»Ỵjṭ⁷ẋǬȧẠƲ
ṖḟÐḟ”4Ḣµñ³,Ç

A full program. The inputs are a list of strings and a date taken as integer days since January the first 1970 (making 17264 April the eighth 2017)

Try it online!

How?

Ñȧ$“&nbsp;”,¤j$€io.ɗ¦@Ṗj@€“<s>“</s>”oj⁾,  - Link 1: L = list of characters ("4...4") OR integer (0),
                                          -         R = list of lists of characters (the strings provided to the program)
  $                                       - last 2 links as a monad:
Ñ                                         -   call next Link (2) as a monad
                                          -   ...gets: is date input to program greater than 2017-04-07?
 ȧ                                        -   AND (if so gets the value of L, else 0), say X
                    ¦@                    - sparse application (with swa@pped @rguments)...
                      Ṗ                   - ...with right argument = popped R (without it's rightmost entry)
                   ɗ                      - ...to: last 3 links as a dyad
                i                         -          first index of X in popped R (0 if no found, so 0->0)
                  .                       -          literal 0.5
                 o                        -          OR (change any 0 to 0.5)
                                          -        ...i.e. index of "4...4" if L was one or 0.5, an invalid index
              $€                          - ...do: for €ach... last 2 links as a monad:
            ¤                             -          nilad followed by link(s) as a nilad:
   “&nbsp;”                               -            literal list of characters = "&nbsp;"
           ,                              -            pair (with itself) = ["&nbsp;", "&nbsp;"]
             j                            -            join (with the item) e.g.: "&nbsp;444&nbsp;" or ["&nbsp;", 0, "&nbsp;"]
                          “<s>“</s>”      - literal list of lists of characters = ["<s>", "</s>"]
                       j@€                - for €ach... join (with swa@pped @rguments)
                                    o     - OR with R (vectorises, so adds the popped entry back onto the right-side)
                                      ⁾,  - literal list of characters = ", "
                                     j    - join

⁴>⁽A€ - Link 2: greater than 2017-04-07?
⁴     - program's 4th argument (2nd input)
  ⁽A€ - literal 17263 (days(2017-04-07 - 1970-01-01))
 >    - greater than?

“¢⁻$gẆẠ⁷Ṭ]ḳṁṛż?=çỊI×V»Ỵjṭ⁷ẋǬȧẠƲ - Link 3: L = list of characters ("4...4") OR integer (0)
“¢⁻$gẆẠ⁷Ṭ]ḳṁṛż?=çỊI×V»           - compressed list of characters = "crossed out \n is still regular \n ;("
                     Ỵ           - split at newlines = ["crossed out ", " is still regular ", " ;("]
                      j          - join with L
                        ⁷        - literal newline character
                       ṭ         - tack (add to the front)
                              Ʋ  - last 4 links as a monad:
                          Ç      -   call last Link (2) as a monad
                           ¬     -   NOT
                             Ạ   -   All (1 if L is "4...4", 0 if L is 0)
                            ȧ    -   AND
                         ẋ       - repeat (i.e. get the list of characters to print or an empty list)

ṖḟÐḟ”4Ḣµñ³,Ç - Main Link: list of strings, integer (days since 1970-01-01)
Ṗ            - pop (list of strings without it's rightmost entry)
  Ðḟ         - filter discard if:
 ḟ           -   filter discard any which are in...
    ”4       -   ...literal character '4'
      Ḣ      - head (yields 0 if list is now empty)
       µ     - new monadic chain, call that X
         ³   - program's 3rd argument (1st input) - call that Y)
        ñ    - call next Link (1) as a dyad (i.e. f1(X, Y))
           Ç - call last Link (3) as a monad (ie. f3(X))
          ,  - pair
             - implicit (smashing) print
\$\endgroup\$
  • 1
    \$\begingroup\$ You forgot to remove the input from another challenge in your TIO. ;) Nice answer regardless. Would you mind adding an explanation? And rofl at that 444-byte count. I don't believe it one bit that you started with that, unless you added comments. ;p \$\endgroup\$ – Kevin Cruijssen Aug 12 '18 at 9:18
  • \$\begingroup\$ Opps, thanks. I'll add an explanation shortly. \$\endgroup\$ – Jonathan Allan Aug 12 '18 at 10:16
  • 1
    \$\begingroup\$ 444 version no comments, numbers rather than compressed strings \$\endgroup\$ – Jonathan Allan Aug 12 '18 at 10:17
  • \$\begingroup\$ ...ah the 444 version has a bug - its using days since 1969-12-31 not since 1970-01-01 as the golfed version does >_< (naive fix is still 444) \$\endgroup\$ – Jonathan Allan Aug 12 '18 at 12:31
4
\$\begingroup\$

Python 2, 208 204  203 201 197 bytes

Takes input as a list of strings, and an int of yyyymmDD

def f(l,d):
 A=a=d>20170407;r=[]
 for n in l[:-1]:x=set(n)=={'4'};S='&nbsp;'*x*a;r+=['<s>'+S+n+S+'</s>'];A=x*n or A
 print', '.join(r+l[-1:])+'\ncrossed out %s is still regular %s ;('%(A,A)*(a*A<A)

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Excel VBA, 217 bytes

VBE immediate window function that takes input array from range [A:A], and date from range [B1] and outputs to the console.

c=[Count(A:A)]:d=[B1]>42832:For i=1To c-1:n=Cells(i,1):l=InStr(44444,n):s=IIf(d*l,"&nbsp;",""):v=IIf((d=0)*l,n,v):?"<s>"s;""&n;s"</s>, ";:Next:?""&Cells(i,1):?IIf(v,"crossed out "&v &" is still regular "&v &" ;(","");

Ungolfed and Commented

c=[Count(A:A)]                  ''  Get numer of elements
d=[B1]>42832                    ''  Check if date is after 7 Apr 2017,
For i=1To c-1                   ''  Iterate over index
n=Cells(i,1)                    ''  Get array val at index
l=InStr(44444,n)                ''  Check if val is all 4s
s=IIf(d*l,"&nbsp;","")          ''  If after 7 Aug 2017, and All 4s, let `s` be "&nbsp;"
v=IIf((d=0)*l,n,v)              ''  If all 4s, and not after date, let v hold n, else hold v
?"<s>"s;""&n;s"</s>, ";         ''  Print striked vales, with "&nbsp;", if applicable
Next                            ''  Loop
?""&Cells(i,1)                  ''  Print last value in array
                                ''  (below) Print meme, if needed
?IIf(v,"crossed out "&v &" is still regular "&v &" ;(","");

-2 bytes for changing date format to YYYYMMDD

-1 byte for comparing to 42832 (int value for 07 Apr 2017), Thanks @Neil

-2 bytes for removing 1, from the InStr statement, Thanks @SeaDoggie01

\$\endgroup\$
  • \$\begingroup\$ I guess For i=1To~-c instead of For i=1To c-1 isn't possible in Excel VBA? If I recall correctly Bitwise not is Not instead of ~, or are both possible? (Note that I know next to nothing of Excel VBA, so I'm probably saying something stupid here. ;p) \$\endgroup\$ – Kevin Cruijssen Aug 8 '18 at 13:05
  • \$\begingroup\$ @KevinCruijssen Yeah, bitwise not is Not , so no ~ :( \$\endgroup\$ – Taylor Scott Aug 8 '18 at 13:07
  • 1
    \$\begingroup\$ I think you can save more bytes by changing the date format back to date and comparing against 42832 (the integer value of 2017-04-07). \$\endgroup\$ – Neil Aug 8 '18 at 15:24
  • \$\begingroup\$ I think you can save 2 bytes by removing the "1," from the instr (it's optional) \$\endgroup\$ – seadoggie01 Sep 11 '18 at 19:25
2
\$\begingroup\$

Retina 0.8.2, 130 bytes

$
;42833
O`;.{5}
\b(4+),(?=.*;42833;)
&$1&,
&
&nbsp;
.{12}$

\b(4+),.*
$&¶crossed out $1 is still regular $1 ;(
(.+?),
<s>$1</s>, 

Try it online! Link includes test cases. Uses Excel date stamps (days since 1899-12-31 but including 1900-02-49). 141 bytes for a version that takes ISO dates:

$
;2017-04-08
O`;.{10}
\b(4+),(?=.*;2017-04-08;)
&$1&,
&
&nbsp;
.{22}$

\b(4+),.*
$&¶crossed out $1 is still regular $1 ;(
(.+?),
<s>$1</s>, 

Try it online! Link includes test cases. Explanation:

$
;2017-04-08

Append the cut-off date to the input.

O`;.{10}

Sort the dates. If the given date is on or after the cut-off date then the first date will be the cut-off date.

\b(4+),(?=.*;2017-04-08;)
&$1&,
&
&nbsp;

In that case, wrap the 4+ in &nbsp; (using two stages as it saves a byte).

.{22}$

Delete the dates as they have done their job.

\b(4+),.*
$&¶crossed out $1 is still regular $1 ;(

If there's an unspaced 4+, then append the meme.

(.+?),
<s>$1</s>, 

Strike out all of the obsolete byte counts.

\$\endgroup\$
  • \$\begingroup\$ You can save 5 bytes by taking the date-format without -. \$\endgroup\$ – Kevin Cruijssen Aug 8 '18 at 9:11
  • \$\begingroup\$ @KevinCruijssen I could save even more bytes by asking for it as an Excel date (days since 1899-12-31). How far can I go with this? \$\endgroup\$ – Neil Aug 8 '18 at 10:13
  • \$\begingroup\$ Hmm.. You know what, that's also fine by me. How the if-statement for the date April 8th, 2017 is done I don't really care. It's not the major part of this challenge. \$\endgroup\$ – Kevin Cruijssen Aug 8 '18 at 11:12
  • \$\begingroup\$ That would be 42832 for April 8th, 2017 I assume? \$\endgroup\$ – Kevin Cruijssen Aug 8 '18 at 11:18
  • \$\begingroup\$ @KevinCruijssen My Excel says that's the 7th. \$\endgroup\$ – Neil Aug 8 '18 at 11:33
1
\$\begingroup\$

Ruby, 208 184 180 bytes

TIO-test

Thanks for @KevinCruijssen for saving 2 bytes!

->n,d{*h,t=n;i=20170408>d;f=?\n;h.map{|u|o=u.digits|[]==[4];f=o&&i ?f+"crossed out #{u} is still regular #{u} ;(":f;o&&!i ?"<s>&nbsp;#{u}&nbsp;</s>":"<s>#{u}</s>"}*", "+", #{t}"+f}

It's a lambda function that takes a list of numbers and an integer as a date in the format of YYYYmmdd.

\$\endgroup\$
  • \$\begingroup\$ Would it be possible to add a TIO-link with test code? And switching formats so it's an integer input would indeed save some bytes. :) \$\endgroup\$ – Kevin Cruijssen Aug 9 '18 at 12:21
  • \$\begingroup\$ @KevinCruijssen Added link ;) \$\endgroup\$ – Peter Lenkefi Aug 9 '18 at 12:27
  • \$\begingroup\$ Thanks! +1 from me. You can save 2 bytes by removing the spaces after the ?. Also, for your TIO, you can split your actual submission code and test code with the header/footer, like this. :) \$\endgroup\$ – Kevin Cruijssen Aug 9 '18 at 12:41
1
\$\begingroup\$

JavaScript, 194 bytes

(a,d,l=a.pop(),n=a.find(x=>/^4+$/.exec(x)),s=a.map(n=>`<s>${n}</s>, `).join``+l)=>d<1491609600?n?s+`
crossed out ${n} is still regular ${n} ;(`:s:s.replace(/>(4+)</g,(_,m)=>`>&nbsp;${m}&nbsp;<`)

f=
(a,d,l=a.pop(),n=a.find(x=>/^4+$/.exec(x)),s=a.map(n=>`<s>${n}</s>, `).join``+l)=>d<1491609600?n?s+`
crossed out ${n} is still regular ${n} ;(`:s:s.replace(/>(4+)</g,(_,m)=>`>&nbsp;${m}&nbsp;<`)


const date = s => Date.parse(s) / 1000
for(const output of [
	f([50, 48, 44, 41], date('January 1, 2017')),
	f([500, 475, 444, 301, 248], date('June 2, 2018')),
	f([8, 6, 4], date('December 5, 2017')),
	f([8, 6, 4, 3, 2], date('September 15, 2015')),
	f([119, 99, 84, 82, 74, 60, 51, 44, 36, 34], date('February 29, 2016')),
	f([404, 123, 44], date('March 4, 2016')),
	f([4, 3], date('April 8, 2017')),
	f([44], date('October 22, 2017')),
	f([50000, 44444, 1500], date('August 1, 2018')),
	f([50, 38, 23], date('September 8, 2001')),
]) console.log(output)

\$\endgroup\$
1
\$\begingroup\$

Haskell, 227 bytes

i[]=1>0;i('4':s)=i s;i(_:_)=0>1
f l d=m l++c where a=head$filter i l;t d|d<42832=("","\ncrossed out "++a++" is still regular "++a++" ;(")|1>0=("&nbsp;","");(b,c)=t d;w n|i n=b++n++b|1>0=n;m[n]=n;m(x:s)="<s>"++w x++"</s>, "++m s

Try it online! Run f with list l and date d. 42832 is the changing date.

\$\endgroup\$
  • \$\begingroup\$ Would it be possible to add a TIO-link with test code? \$\endgroup\$ – Kevin Cruijssen Aug 9 '18 at 12:21
  • \$\begingroup\$ @KevinCruijssen in Russia it's banned \$\endgroup\$ – Евгений Новиков Aug 9 '18 at 15:38
  • \$\begingroup\$ Oh, didn't knew that. Well, I don't know Haskell too well, otherwise I would have tested it myself a bit. But the code itself seems logical, so +1 from me nonetheless. \$\endgroup\$ – Kevin Cruijssen Aug 9 '18 at 16:39
  • \$\begingroup\$ @KevinCruijssen you can copy code to TIO, make link and add it to post \$\endgroup\$ – Евгений Новиков Aug 9 '18 at 20:12
  • \$\begingroup\$ @KevinCruijssen TIO is banned by mistake, but I'm too lazy to use proxy/contact ISP about it \$\endgroup\$ – Евгений Новиков Aug 9 '18 at 20:18
1
\$\begingroup\$

JavaScript (Node.js), 173 bytes

a=>d=>a.map(x=>--i<1?x:`<s>${(b=/^4+$/.exec(x)?(c=x,d)<14915808e5?n=[]:"&nbsp;":"")+x+b}</s>`,n="",c=0,i=a.length).join`, `+(n&&`
crossed out ${c} is still regular ${c} ;(`)

Try it online!

Using curry syntax f(array)(js_timestamp)

\$\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.