Computer programming thread
- hsilman
- ✓ Registered User
- Posts: 2842
- Joined: Fri Sep 15, 2017 8:31 am
- Age: 39
Computer programming thread
This got a lot of responses previously, so let's start it again.
What's everyone up to?
I enrolled in school for real after finishing CS50X. Taking intro CS(Java), which as Hanley predicted would be mind numbingly dull if it was my only class. Easy stuff, though I will be doing JavaFX GUI stuff, which I haven't before.
I'm also taking Intro to Android Development, which complements the other class well. It's supposed to be taken with CS 102, but I figured I'd done enough work to adapt. It's filling most of my time, lots of stuff to learn.
What's everyone up to?
I enrolled in school for real after finishing CS50X. Taking intro CS(Java), which as Hanley predicted would be mind numbingly dull if it was my only class. Easy stuff, though I will be doing JavaFX GUI stuff, which I haven't before.
I'm also taking Intro to Android Development, which complements the other class well. It's supposed to be taken with CS 102, but I figured I'd done enough work to adapt. It's filling most of my time, lots of stuff to learn.
- mgil
- Shitpostmaster General
- Posts: 8483
- Joined: Wed Sep 13, 2017 5:46 pm
- Location: FlabLab©®
- Age: 49
Re: Computer programming thread
I'm currently avoiding code. I'm usually telling people what to code now. I'll be coding again soon, probably.
- Idlehands
- Sunshine + Unicorns
- Posts: 1451
- Joined: Fri Sep 15, 2017 10:40 am
- Contact:
Re: Computer programming thread
My favorite interview question is "what's the last script you wrote"
Even to folks that are interviewing for a job that requires 0 coding. Cause you should still be a techie nerd that wants to tinker!
Even to folks that are interviewing for a job that requires 0 coding. Cause you should still be a techie nerd that wants to tinker!
- mgil
- Shitpostmaster General
- Posts: 8483
- Joined: Wed Sep 13, 2017 5:46 pm
- Location: FlabLab©®
- Age: 49
Re: Computer programming thread
A: Romeo and Juliet [drops mic and walks out]Idlehands wrote:My favorite interview question is "what's the last script you wrote"
- iamsmu
- Registered User
- Posts: 4970
- Joined: Sun Sep 17, 2017 5:52 pm
- Location: Handicap: +.3
- Age: 49
- Contact:
Re: Computer programming thread
You have a 5 number random number generator (1-5). Based on the 1-5 generator, produce a 1-7 generator that gives an evenly distributed set of numbers.
- iamsmu
- Registered User
- Posts: 4970
- Joined: Sun Sep 17, 2017 5:52 pm
- Location: Handicap: +.3
- Age: 49
- Contact:
Re: Computer programming thread
Let's start with a much easier question. This one is a good warm up.
You have a sorted list of integers with no duplicates. There is no way to determine its length. Describe an algorithm for determining if any given number is contained in the list. (And in what time does your algorithm operate in.)
You have a sorted list of integers with no duplicates. There is no way to determine its length. Describe an algorithm for determining if any given number is contained in the list. (And in what time does your algorithm operate in.)
- iamsmu
- Registered User
- Posts: 4970
- Joined: Sun Sep 17, 2017 5:52 pm
- Location: Handicap: +.3
- Age: 49
- Contact:
Re: Computer programming thread
Those two were on the top of my head. . . I just dug up a sheet with a bunch of other interview questions I used to ask. Damn. I'd never get through my interviews at this point. I haven't done anything but write some groovy for home automation stuff in 7 years. It's a little sad how much I've forgotten. Oh well. I'd have to at least work through a data structures and algorithms text book before I could even think about interviewing again.
- cwd
- Registered User
- Posts: 3400
- Joined: Fri Sep 15, 2017 8:34 am
- Location: central Ohio
- Age: 58
Re: Computer programming thread
Bonus points if your "infinite" singly-linked list can have loops, and your algorithm will still return eventually rather than busy-hanging.iamsmu wrote:Let's start with a much easier question. This one is a good warm up.
You have a sorted list of integers with no duplicates. There is no way to determine its length. Describe an algorithm for determining if any given number is contained in the list. (And in what time does your algorithm operate in.)
- Root
- Grillmaster
- Posts: 1997
- Joined: Fri Sep 15, 2017 8:28 am
- Location: Western Upper Lower
- Age: 44
Re: Computer programming thread
He didn't say it was a linked list. In fact, if it was, this problem would be trivial.cwd wrote:Bonus points if your "infinite" singly-linked list can have loops, and your algorithm will still return eventually rather than busy-hanging.iamsmu wrote:Let's start with a much easier question. This one is a good warm up.
You have a sorted list of integers with no duplicates. There is no way to determine its length. Describe an algorithm for determining if any given number is contained in the list. (And in what time does your algorithm operate in.)
- Root
- Grillmaster
- Posts: 1997
- Joined: Fri Sep 15, 2017 8:28 am
- Location: Western Upper Lower
- Age: 44
Re: Computer programming thread
This is just a binary search of the first n - f + 1 elements of the list, where n is the number we're searching for, and f is the integer in the first element.iamsmu wrote:Let's start with a much easier question. This one is a good warm up.
You have a sorted list of integers with no duplicates. There is no way to determine its length. Describe an algorithm for determining if any given number is contained in the list. (And in what time does your algorithm operate in.)
Edit: Well, it resembles a binary search.
-
- Registered User
- Posts: 278
- Joined: Sat Sep 16, 2017 7:12 am
Re: Computer programming thread
Books and project sites for n00bs?
- hsilman
- ✓ Registered User
- Posts: 2842
- Joined: Fri Sep 15, 2017 8:31 am
- Age: 39
Re: Computer programming thread
How do you determine the high index element if you don't know the list length? Can't just say the nth index.Root wrote:This is just a binary search of the first n - f + 1 elements of the list, where n is the number we're searching for, and f is the integer in the first element.iamsmu wrote:Let's start with a much easier question. This one is a good warm up.
You have a sorted list of integers with no duplicates. There is no way to determine its length. Describe an algorithm for determining if any given number is contained in the list. (And in what time does your algorithm operate in.)
Edit: Well, it resembles a binary search.
But maybe you're saying the same thing.
First, find your bounds. I'd just start at 0th for low and 1th for high. Is 1th higher than n? If yes, binary search. If not, high = 2*1tg, repeat. Go until the high bound is more than your number or you reach the end.
- hsilman
- ✓ Registered User
- Posts: 2842
- Joined: Fri Sep 15, 2017 8:31 am
- Age: 39
Re: Computer programming thread
Define noob. And what's the goal?GregoryDomnin wrote:Books and project sites for n00bs?
- Root
- Grillmaster
- Posts: 1997
- Joined: Fri Sep 15, 2017 8:28 am
- Location: Western Upper Lower
- Age: 44
Re: Computer programming thread
Well, they can't just tell you there's "no way" to know the length. At the very least, you need to get an indication when you attempt to access the list beyond its bounds. So I'd just assume that you don't know the length *up front*.
But you also know that the number you're searching for isn't beyond the index (n - f + 1)*, because there are no duplicates.
*Again, where n is the number you're searching for, and f is the first element in the list.
But you also know that the number you're searching for isn't beyond the index (n - f + 1)*, because there are no duplicates.
*Again, where n is the number you're searching for, and f is the first element in the list.
- iamsmu
- Registered User
- Posts: 4970
- Joined: Sun Sep 17, 2017 5:52 pm
- Location: Handicap: +.3
- Age: 49
- Contact:
Re: Computer programming thread
Root wrote:This is just a binary search of the first n - f + 1 elements of the list, where n is the number we're searching for, and f is the integer in the first element.iamsmu wrote:Let's start with a much easier question. This one is a good warm up.
You have a sorted list of integers with no duplicates. There is no way to determine its length. Describe an algorithm for determining if any given number is contained in the list. (And in what time does your algorithm operate in.)
Edit: Well, it resembles a binary search.
Exactly. I just requires that you realize that the number couldn't be in a position larger than the number itself. ( In interview contexts some people struggle with that. You can get them talking about what they know about the problems and see how they think. It's kind of an ice breaker. ) That gives you a length to work with. So, ya, it's just a binary search. . . . O log (n)
[There is no list like this. It's hypothetical. . . . You can just say that it trails off into MAXINT forever and ever. . . .]
- cwd
- Registered User
- Posts: 3400
- Joined: Fri Sep 15, 2017 8:34 am
- Location: central Ohio
- Age: 58
Re: Computer programming thread
If it's an indexable array, why don't we know the length?Root wrote: He didn't say it was a linked list. In fact, if it was, this problem would be trivial.
- Root
- Grillmaster
- Posts: 1997
- Joined: Fri Sep 15, 2017 8:28 am
- Location: Western Upper Lower
- Age: 44
Re: Computer programming thread
I don't know. The problem wouldn't even change that much if we did know the length.cwd wrote:If it's an indexable array, why don't we know the length?Root wrote: He didn't say it was a linked list. In fact, if it was, this problem would be trivial.
It's just a weird question.
- hsilman
- ✓ Registered User
- Posts: 2842
- Joined: Fri Sep 15, 2017 8:31 am
- Age: 39
Re: Computer programming thread
usually when I read this question, it says it's an "infinite array".cwd wrote:If it's an indexable array, why don't we know the length?Root wrote: He didn't say it was a linked list. In fact, if it was, this problem would be trivial.
I was going to ask why the number can't be at an index beyond itself, but I answered my own question when I was asking it. So I guess just a binary search of n-f+1 makes perfect sense. My answer added extra complexity that I don't think saves time.
- Hanley
- Strength Nerd
- Posts: 8752
- Joined: Fri Sep 15, 2017 6:35 pm
- Age: 46
Re: Computer programming thread
Mostly trying to figure out what the hell I was thinking when I decided to learn to code at age 39.hsilman wrote:What's everyone up to?.
- Hanley
- Strength Nerd
- Posts: 8752
- Joined: Fri Sep 15, 2017 6:35 pm
- Age: 46
Re: Computer programming thread
If you're brand-baby new, this site is nice: http://codingbat.com/GregoryDomnin wrote:Books and project sites for n00bs?
Project Euler is all about devising efficient solutions (problems range from pretty-damned-to-east to holy-fuck hard): https://projecteuler.net/
Not sure about books. Every book I've tried sorta sucked.