Programming

This is a take home assignment for a job interview?

yeah. Not hitting any rate limits at least.

FFS - hire me for a couple weeks and I’ll build this thing for you, then you can decide if you want to keep me on.

lol couple weeks. I’m almost done but its gonna be like 8 hours total to make it not terrible and do the “optional” parts (hint: they aren’t optional). At least its for principal. api is garbage though lol can’t infer anything. IDK whatever

Are you using Mobx and Sass? I’ve never used Mobx so that would slow me down. CSS would slow me down but presumably that’s a requirement for this job. Are you using something off the shelf like react table for pagination and search?

I’m debating whether or not to use mobx. Never have before but it can’t be much different than redux. SASS support comes with create react app. All HTML baby any dipshit can throw mui at stuff is my thinking here.

I’m still my high school self - my boss boss wanted me to prepare a presentation to solve some problem we’re facing with ssl certs, i’ve been in bed with fever for 3 days and finally got up to do it (it’s in 3 hours) and buried in my drive i found a full blown presentation i’d made on this exact topic 2 years ago.

jackpot, reminds me of when i used to recycle old A+ papers in english class.

I have a Python question. I want to take a list and replace elements with an empty string if the element repeats the previous element. For example, I want to turn

['a', 'b', 'b', 'b', 'c', 'c']

into

['a', 'b', '', '', 'c', '']

One way to do this is

new = old[:1]
for i, o in enumerate(old[1:]):
    new.append(o if o != old[i] else '')

This seems a little kludgy, but I can’t think of a more elegant solution. Any ideas?

maybe this is why im failing interviews - my instinct is to just do this

cpy = input_list[::]
for i in range(len(input_list)):
    if i > 0 and input_list[i-1] == input_list[i]:
        cpy[i] = ‘’

seems way more readable to me than any syntactic sugar crap

no way its time complexity is worse than O(N)

if you wanted to do it in place for fanciness points im sure you could but it’d read a bit uglier

1 Like

For Python 3.10+:

new = old[:1]
new.extend(e2 if e1 != e2 else "" for e1, e2 in itertools.pairwise(old))

I don’t see any reason that’s actually better than your approach though. Just a chance to impress itertools nerds.

1 Like

can anyone explain something that’s been bugging me for a long time now?

“please enter the last 4 digits of your ssn followed by the pound sign” on automated robo assist stuff. ok - the # is presumably acting as a delimiter for the software to understand my input is over. why can’t it just stop accepting input and realize i’m done after 4 digits have been entered, since that’s all it expects and all that will be valid?

Because that’s the way it is done. Starting to change, some 2fa that give you 6 characters will auto submit on the 6th character but it’s rare. Phone is terrible though since there’s no delete key on a phone.

1 Like

funny enough on the same calls sometimes it’ll be able to figure it out in some cases but not others. I figured there was something I was missing.

I’m having an issue joining two large tables in Bigquery (Google Cloud) and am throwing this out there in the hope that someone might happen to have an idea.

I want to use the following join condition:

table1.attribute = substring(table2.attribute, 4, length(table1.attribute))

I have to specify the length in the substring because table2.attribute has a load of garbage at the end of indeterminate length.

With the above join condition the query does run but it never completes (I’ve let it run for half an hour before killing it), and the problem seems to be that I’m referring to table1.attribute on both sides of the join.

The only way I can get it to work is to use hardcoded values instead of length(table1.attribute) and union multiple queries together with the known lengths, but I want to avoid this as I can’t guarantee that in the future there won’t be other lengths that I haven’t covered.

I’ve also tried using:

SUBSTRING(table2.attribute, 4) LIKE CONCAT(table1.attribute,’%’)

And:

REGEXP_CONTAINS(table2.attribute, table1.attribute) = true

But am hitting the same issue where the query just keeps running.

I’ve also tried joining to a separate subquery/temp table that contains all of the distinct lengths of table1.attribute in the current data , but this takes over 15 mins to complete, whereas with the hardcoding method it takes a little over one minute, so not viable.

None of my technical colleagues have been able to come up with an alternative, and it’s driving me mad!

Can you truncate the attributes to the length you want and read them into a temp table(s), then do the join from that?

I don’t understand what the big gotcha is with the api call. You are just making api calls to the Star Wars API until next_page is null.

These companies might as well just have you pair with them on the task for an hour or two and it should be obvious how quick you are on your feet.

No because I don’t know how much of table2.attribute I need to retain. It usually has some crap on the end, and the length of that is unknown. Somewhere in the middle of that string is the value I want to join to.

E.g

Table 1 L56374848
Table 2 ABCL56374848282635

Table 1 L174888
Table 2 ABCL174888648362262578

Is it a number to letter transition that you could try to chop by?

Assuming you can’t get false positives, and you could knock out 90% of table 1 with a temp table for table 2 based on the number/letter split, then maybe the last 10% of table 1 against the original table 2 wouldn’t take forever.

How many different possible lengths are there in table 1? It might still be quicker to make 4 temp tables and do the join on those. Start with the longest length temp table, and remove table 1 matches after each join.

No it’s mostly numbers. Sorry I should have been clearer, I only used letters just to make it more visible. I’ve edited the post to use numbers instead.

We can assume no false positives.

There are 5 distinct lengths for table 1, but no guarantee that additional lengths won’t appear in the future, which would mean a code change every time this happens using my hardcoding and union method (even though it runs well).

Where does the data in table 2 come from? I assume you can’t check it against table 1 when it’s entered and make a new column for the table 1 match? You could do the same for table 1 if it’s entered piecemeal and it’s your data.

Also maybe your hardcoded method could be softcoded based on a dynamic list of all the possible lengths in table 1.