Software Development and Programming Careers (Official Discussion Thread)

cobra

Superstar
Supporter
Joined
Apr 24, 2017
Messages
11,364
Reputation
-1,281
Daps
50,029
Did an interview today where I had to convert a binary number (represented as a linked list) to an integer

so 1 -> 0 -> 1 = 5

Used 1 iteration of the linked list to figure out the length and used that to calculate the integer value during the 2nd pass

then I was asked to solve it in one pass. I didn’t know how to do this…apparently the solution is bit manipulation
 
  • Wow
Reactions: F K

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,852
Reputation
25,252
Daps
131,941
Did an interview today where I had to convert a binary number (represented as a linked list) to an integer

so 1 -> 0 -> 1 = 5

Used 1 iteration of the linked list to figure out the length and used that to calculate the integer value during the 2nd pass

then I was asked to solve it in one pass. I didn’t know how to do this…apparently the solution is bit manipulation
Probably some shyt like shift left then add the bit? I'm not a fan of these, I'd like to see the real world application of such a problem.
 

null

...
Joined
Nov 12, 2014
Messages
29,220
Reputation
4,894
Daps
46,431
Reppin
UK, DE, GY, DMV
Did an interview today where I had to convert a binary number (represented as a linked list) to an integer

so 1 -> 0 -> 1 = 5

Used 1 iteration of the linked list to figure out the length and used that to calculate the integer value during the 2nd pass

then I was asked to solve it in one pass. I didn’t know how to do this…apparently the solution is bit manipulation

value = 0
mask = 1
for (element : elements.reverse()) {
value += mask * element // or use IF guard
mask.left bit shift
}
print value

that should do it:hhh:

live tests :hhh:





:hhh:
 

null

...
Joined
Nov 12, 2014
Messages
29,220
Reputation
4,894
Daps
46,431
Reppin
UK, DE, GY, DMV
Is it a single pass if you reverse then iterate? That's 2 passes right? My first thought was similar to what you have.

no it is one. you know rbegin(), rend() vs. begin(), end()

or declarative programming.

just because you reverse it doesn't mean that the values were all actually reveresed. you know functional programming lists and change on write - until then it is only a logical re-ordering.

so take c++ for example quite aside from rbegin/rend you could implement a lazy change on write that reverses by just swapping two pointers. or can do a shallow copy into another list that just reverses the pointers on init.

so nope it is not two passes.

and even if they were really reordered that still ain't 2 passes.
 
Last edited:

null

...
Joined
Nov 12, 2014
Messages
29,220
Reputation
4,894
Daps
46,431
Reppin
UK, DE, GY, DMV
Did an interview today where I had to convert a binary number (represented as a linked list) to an integer

so 1 -> 0 -> 1 = 5

Used 1 iteration of the linked list to figure out the length and used that to calculate the integer value during the 2nd pass

then I was asked to solve it in one pass. I didn’t know how to do this…apparently the solution is bit manipulation

if the list was uni-directional and you didn't know how long the list was you could just assign the highest possible place value to the first element and then right bit shift to add each successive list place value to the value running total.

when you have finished the list then shift right shift the running total result until the last column value you assigned to has been shifted into the units position

then that is your answer.

so you shift the mask N times for a list of N elements and thus add N times and then you shift the result 63-N times to shift the result to line up with the units column...

whats the highest place value?

2^63 unsigned on a 64 bit arch .. so a big number

hopefully :whew:

bit expensive but if they want 1 pass then ... :yeshrug: also bit shifts are fast.

i should add that the '+' can be replaced by a binary "||" i.e. "or" when summing up as that is cheaper

-

and yeah there are some assumptions about endianness in the above big vs small. and everything is is an unsigned integer value for the bare metal languages (c/c++/...).

Endianness - Wikipedia
 

Don Juan

Pro
Joined
Mar 11, 2022
Messages
259
Reputation
245
Daps
626
Reppin
San Antonio
Understand Myself - Understand Myself

^Life changing personality test that costs $10

Humanizing GPT-3: Introducing OCEAN

I’m a researcher, not a programmer. Don’t walk away from this paper disappointed by the lack of a detailed technical explanation or concrete examples of the ideas within. I have never produced text written by GPT-3. What attracts me to the technology is the potential to combine personality and technology along the lines of the English language. Fundamentally, GPT-3 is a genius AI designed to produce English text that passes the Turing test. People are excited by its ability to predict and mimic, but in it I see the potential for so much more.

Let me introduce you to the Big 5, or OCEAN model of personality. Like GPT-3, OCEAN is designed around a massive library of the English language. That should be reason enough to explore combining the two. How so? It’s simple. OCEAN further breaks down into two components per trait as follows, openness and intellect, industriousness and orderliness, enthusiasm and assertiveness, politeness and compassion, and finally, withdrawal and volatility. Straightforwardly, assign a value of 1–100 for each of the ten traits and the output will align with that of any English speaking person. Personality is a sliding scale based on frequencies. Adjusting the frequencies produces different personalities.

Technology lacks personality because we don’t have sufficient mental models, even for ourselves. In The Rosales Project, I detailed how much work it took to reach this point of understanding, and I’m giving the technical community the chance to stand on my shoulders, as well as the shoulders of others, who have done great work in fields such as language and psychology, which are becoming rapidly more relevant. MBTI, enneagram, and even Big 5 mental models that don’t allow for further breakdowns in the components just aren’t good enough to develop a strong understanding of personality or how to implement it from a mathematical perspective. What I’m recommending in this paper might be detailed enough to work.

What GPT-3 lacks is emotional intelligence. The paragraphs often come across as piles of nothing. Not only is the scope of information provided limited to what was originally input for the system to copy, meaning that the output is limited in terms of capacity for surprise, but the writing also fails to achieve any of the emotional appeal that even a 3rd grader could produce in their writing by virtue of being human. I’m suggesting a mechanism for humanization of this technology by introducing the audience to a mathematical and statistical basis for the emotional range we all exhibit in our use of language. Words only account for 7% of all communication among human beings, with tone and body language being far more important to us by nature. We are already limited to working with a fraction of what holds our attention when it comes to AI text generation, so every mental model we can use to improve it helps.

Machine learning algorithms can become equipped with personalities that are modelled after real human emotional ranges. OCEAN accounts for personality in both the macro and the micro. A person is both their overall frequency of emotion, and the way that those frequencies affect their slightest utterances. People exceptionally high in volatility use strong language and take longer to calm down. People who are low in enthusiasm are less upbeat or happy than those who are high, and are less likely to be in the mood to crack jokes. People who are low in compassion and politeness are less interested in the problems of others and more likely to be blunt and to interrupt. I see no reason that these same mental models can’t be applied to our AI for the purpose of humanizing a technology that we all see as potentially valuable.

In the next part, I will discuss some possible applications of the combination of this technology with OCEAN, as well as some of the practical and moral implications of doing this kind of work and research. Thanks for reading.

I want to program a website to search big five personality test results and link people together. Like a social media where you could see each other's stats.

What do you guys think?
 
Joined
Apr 3, 2014
Messages
71,910
Reputation
17,058
Daps
305,943
Understand Myself - Understand Myself

^Life changing personality test that costs $10



I want to program a website to search big five personality test results and link people together. Like a social media where you could see each other's stats.

What do you guys think?




I think it's a good enough idea that you should make it private.
 

Mike809

Veteran
Supporter
Joined
Oct 15, 2015
Messages
16,097
Reputation
3,651
Daps
82,072
Reppin
Bronx
I should be done with my project by tomorrow night or thursday.

just have to configure the backend security to be able to handle roles , and create one for admin and users.
then on the frontend , i have to create an admin page only accessible to admin and give the admin the ability to delete users and approve/deny images.

then host it on netlify/heroku
 
Top