crossed out 44 is still regular 44 ;(

21

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

Kevin Cruijssen

Posted 2018-08-08T08:41:25.650

Reputation: 67 575

Your last test case is missing its date? – Neil – 2018-08-08T08:47:17.557

1@Neil Ah oops.. Fixed. Date doesn't really matter for that one, but added one regardless. Thanks for noticing. – Kevin Cruijssen – 2018-08-08T08:49:01.757

1I 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. – Jonathan Allan – 2018-08-08T09:16:32.143

(I can also confirm that I had used it prior to using it with 44 - I believe that is when I first used them)

– Jonathan Allan – 2018-08-08T09:35:53.480

As we can take input as days since 1889-12-31, can we also take days since 2017-04-08? – TFeld – 2018-08-08T11:49:20.460

Also, can we take the byte-counts as a list of strings instead of integers? – TFeld – 2018-08-08T11:50:34.717

@TFeld Sure. I guess it helps with surrounding it with strings <s> and </s> and a regex-check for 4+ can be used in that case. But yes, taking the list as strings is fine by me. – Kevin Cruijssen – 2018-08-08T12:16:04.440

poke: integer days since arbitrary fixed dates (e.g. 2017-04-07) is fine? (as asked above) – Jonathan Allan – 2018-08-08T20:52:01.677

Your fifth test case appears to be incorrect - should be crossed out 44, not 4. – darrylyeo – 2018-08-10T04:00:49.627

@darrylyeo Fixed – Kevin Cruijssen – 2018-08-10T06:47:37.000

@TFeld Sorry for the late response, somehow missed it. And sorry, but no. That's pushing it a bit too far tbh. Then you'd only have to check <0 or >=0. – Kevin Cruijssen – 2018-08-10T06:49:20.727

Answers

6

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

Jonathan Allan

Posted 2018-08-08T08:41:25.650

Reputation: 67 804

1You 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 – Kevin Cruijssen – 2018-08-12T09:18:48.820

Opps, thanks. I'll add an explanation shortly. – Jonathan Allan – 2018-08-12T10:16:56.320

1444 version no comments, numbers rather than compressed strings – Jonathan Allan – 2018-08-12T10:17:03.723

...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) – Jonathan Allan – 2018-08-12T12:31:11.243

4

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!

TFeld

Posted 2018-08-08T08:41:25.650

Reputation: 19 246

3

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

Taylor Scott

Posted 2018-08-08T08:41:25.650

Reputation: 6 709

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) – Kevin Cruijssen – 2018-08-08T13:05:02.907

@KevinCruijssen Yeah, bitwise not is Not, so no ~ :( – Taylor Scott – 2018-08-08T13:07:18.513

1I 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). – Neil – 2018-08-08T15:24:11.050

I think you can save 2 bytes by removing the "1," from the instr (it's optional) – seadoggie01 – 2018-09-11T19:25:43.457

2

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.

Neil

Posted 2018-08-08T08:41:25.650

Reputation: 95 035

You can save 5 bytes by taking the date-format without -.

– Kevin Cruijssen – 2018-08-08T09:11:36.293

@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? – Neil – 2018-08-08T10:13:09.990

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. – Kevin Cruijssen – 2018-08-08T11:12:07.477

That would be 42832 for April 8th, 2017 I assume? – Kevin Cruijssen – 2018-08-08T11:18:12.233

@KevinCruijssen My Excel says that's the 7th. – Neil – 2018-08-08T11:33:03.073

Oh.. miscalculated then. I used a simple Java script to look at the difference between April 8th 2017 and December 31st 1899. Anyway, let me know when you've change it including the number for all test cases, then I'll add them in the challenge description as well. :) – Kevin Cruijssen – 2018-08-08T11:41:32.167

@KevinCruijssen No, Excel miscalculated, as it doesn't use the century rule for leap years. – Neil – 2018-08-08T15:30:57.370

@KevinCruijssen I've updated my answer to include the Excel date stamps. – Neil – 2018-08-08T20:05:46.597

1

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.

Евгений Новиков

Posted 2018-08-08T08:41:25.650

Reputation: 987

Would it be possible to add a TIO-link with test code?

– Kevin Cruijssen – 2018-08-09T12:21:05.403

@KevinCruijssen in Russia it's banned – Евгений Новиков – 2018-08-09T15:38:28.570

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. – Kevin Cruijssen – 2018-08-09T16:39:14.750

@KevinCruijssen you can copy code to TIO, make link and add it to post – Евгений Новиков – 2018-08-09T20:12:47.100

@KevinCruijssen TIO is banned by mistake, but I'm too lazy to use proxy/contact ISP about it – Евгений Новиков – 2018-08-09T20:18:49.473

i=all(=='4') saves quite a few bytes. Also a let in a pattern guard, that is f l d|let a= .... =m l++c, is shorter than a where. – Laikoni – 2018-08-11T18:15:25.083

1

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.

Peter Lenkefi

Posted 2018-08-08T08:41:25.650

Reputation: 1 577

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. :)

– Kevin Cruijssen – 2018-08-09T12:21:49.573

@KevinCruijssen Added link ;) – Peter Lenkefi – 2018-08-09T12:27:01.263

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. :)

– Kevin Cruijssen – 2018-08-09T12:41:40.923

1

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)

darrylyeo

Posted 2018-08-08T08:41:25.650

Reputation: 6 214

1

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)

Shieru Asakoto

Posted 2018-08-08T08:41:25.650

Reputation: 4 445