Open Side Menu Go to the Top

03-16-2015 , 09:02 PM
Quote:
Originally Posted by e i pi
Anyone here have any experience with SMS api's/services? I recognize the name twilio and they look legit but is there any other company worth looking into? I don't trust google searches for product reviews anymore so thought I'd ask here.
twilio is great. i think they're the biggest player in the market, will be around for a long time, good docs, transparent pricing.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
03-17-2015 , 04:08 AM
i am so burnt out on school. 3 more years probably. and i feel like I've already done so much.

better be worth it
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 08:29 AM
Quote:
Originally Posted by e i pi
Anyone here have any experience with SMS api's/services? I recognize the name twilio and they look legit but is there any other company worth looking into? I don't trust google searches for product reviews anymore so thought I'd ask here.
This is exactly the business I'm in, but Australia only, so useless presumably.

I would advise against going for anything ludicrously cheap, they will be using so called "gray routes" that skirt the borders of legality. Either your customers will find their number/messages scraped for spam, or you will get dubious results. In the worst cases, one supplier reported to my company that messages had been delivered when they actually hadn't. This is obviously a huge problem as there's no way of assessing the extent of it or when it has been fixed.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 10:12 AM
Is DeVry one of those scammy Bull**** schools or is it legitimate?

I could have sworn at one point it was just a useless diploma mill, but maybe I'm thinking of another school.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 10:44 AM
Quote:
Originally Posted by Larry Legend
candybar,

Financial software? Traders?
Yes & no, though I've done that as well. Long before I got serious about software engineering, I once leveraged my programming skills to get a junior position on a trading desk. Which lasted just a few months but it made me question my faith in humanity. Sell-side traders are not very nice people to work with. Bankers and buy-siders at least wear sheep's clothing.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 03:18 PM
Quote:
Originally Posted by Anais
Is DeVry one of those scammy Bull**** schools or is it legitimate?

I could have sworn at one point it was just a useless diploma mill, but maybe I'm thinking of another school.
I think it's more of a tech trade school. We had a sysadmin who graduated from there.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 10:54 PM
Okay, I'm stumped.

I found this problem:
https://www.interviewcake.com/questi...te-5-sided-die

And I was kind of surprised at the answer. So, I created this entirely naive "program" that I would think computes the correct result, but it doesn't compute the correct answer.

I originally had looping, but since it gave the wrong results, I wrote it out like this:

Code:
import random

def r7to5(r):
## 7 / 5 = 1.4
    if 0 <= r < 1.4:
        return 1
    if 1.4 <= r < 2.8:
        return 2
    if 2.8 <= r < 4.2:
        return 3
    if 4.2 <= r < 5.6:
        return 4
    if 5.6 <= r <= 7.0:
        return 5

def rand7():
    return random.randint(0, 7)

def rand5():
    r = rand7()
    return r7to5(r)

d = {}
for i in range(1001):
    a = rand5()
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

print(d)
The output:

Code:
>>> {1: 243, 2: 130, 3: 245, 4: 124, 5: 259}
>>> {1: 252, 2: 118, 3: 244, 4: 123, 5: 264}
>>> {1: 242, 2: 128, 3: 252, 4: 130, 5: 249}
>>> {1: 263, 2: 121, 3: 243, 4: 120, 5: 254}
>>> {1: 265, 2: 146, 3: 235, 4: 121, 5: 234}
>>> {1: 248, 2: 114, 3: 255, 4: 118, 5: 266}
>>> {1: 250, 2: 138, 3: 255, 4: 126, 5: 232}
>>> {1: 236, 2: 123, 3: 245, 4: 121, 5: 276}
>>> {1: 248, 2: 123, 3: 212, 4: 142, 5: 276}
>>> {1: 264, 2: 128, 3: 241, 4: 129, 5: 239}
>>> {1: 254, 2: 137, 3: 244, 4: 117, 5: 249}
What am I missing here?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 11:01 PM
You're looking for 0 to 7 instead of 1 to 7?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 11:10 PM
2 and 4 from r5to7 are the only results that don't correspond to a range including two integers. Rand 7 is giving you an integer-0 to 7 and you're looking for values to fall between, for example, 2.8 through 4.2 which covers both 3 and 4. So 3 or 4 from rand would both map to 3

Hopefully this makes sense I'm on my phone now
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 11:21 PM
I like blackize5's answer better. Couldn't you just loop until you get a number < 6 from the rand 7 function?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 11:24 PM
The question doesn't mention a random integer, just a random number. So I changed it to random.uniform to output a float. Then I changed the ranges in your if statement to match the updated range of possible outputs from rand7().

Code:
def r7to5(r):
## 7 / 5 = 1.4
    if 1.0 <= r < 2.2:
        return 1
    if 2.2 <= r < 3.4:
        return 2
    if 3.4 <= r < 4.6:
        return 3
    if 4.6 <= r < 5.8:
        return 4
    if 5.8 <= r <= 7.0:
        return 5

def rand7():
    return random.uniform(1, 7)

Code:
{1: 212, 2: 217, 3: 196, 4: 169, 5: 207}
{1: 214, 2: 182, 3: 205, 4: 192, 5: 208}
{1: 223, 2: 192, 3: 176, 4: 202, 5: 208}
{1: 219, 2: 210, 3: 205, 4: 187, 5: 180}
.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 11:29 PM
ah, sheesh. I forgot to change randint.

The assertion from the site is this:

This kind of math is generally outside the scope of a coding interview, but: if you know a bit of number theory you can prove that there exists no solution which is guaranteed to terminate. Hint: it follows from the fundamental theory of arithmetic..

Is it saying that there is no guarantee of termination using recurrences or am I missing something else?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 11:34 PM
The solution uses a loop to throw out any value greater than 5 trying again until it gets 5 or less. In theory the rng could never return a number 5 or less.

Nvm the floating point stuff. It's implies that rand7 returns integers 1 to 7
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-17-2015 , 11:37 PM
Doesn't seem like much of a RNG if it's always 6 or 7... The hint about not caring about run time backs that up though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:02 AM
it's a more interesting question with random integers imo.

also apparently you can use the modulus operator with floats in python.

>>> 5.25 % .5
0.25
>>> 5.25 % .20
0.04999999999999971
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:09 AM
>>> def rand5():
... return sum([randint(1,7) for x in range(1,5)]) % 5 + 1

I think this works for integers
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:11 AM
I'm about to start applying for web dev jobs. I have a degree in criminal justice. Should I include that in my resume? I'm trying to avoid including irrelevant information. Am I wrong in thinking that a college degree in an unrelated field is irrelevant information?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:13 AM
I don't think you can use the floating point versions because the final range is closed on both ends, while the others have one open end and one closed end. You'd need to have infinite precision for those ranges to have equal length, but then there would be an infinite number of random numbers to choose from, so how could a random number generator choose one? You could leave the final range open too, but then whenever rand7() returned exactly 7.0, you'd have to reenter rand7() to get a new value just like in the integer version, so you'd have a worst case infinite scenario again, albeit a much, much less likely infinite scenario
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:17 AM
Quote:
Originally Posted by e i pi
>>> def rand5():
... return sum([randint(1,7) for x in range(1,5)]) % 5 + 1

I think this works for integers
I was thinking that too but turns out there is mod bias, mod 5 returns an even remainder for 1 - 7.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:22 AM
Quote:
Originally Posted by Craggoo
I'm about to start applying for web dev jobs. I have a degree in criminal justice. Should I include that in my resume? I'm trying to avoid including irrelevant information. Am I wrong in thinking that a college degree in an unrelated field is irrelevant information?
Take this FWIW as it is strictly an opinion. I would just mention it where you show your education unless you really don't want to have any discussion about it in an interview. I say include it because it shows your determination in acquiring development skills as you were motivated to learn. I could definitely be way off base here though. It may be worth the money to consult with a pro who does resumes for web dev jobs.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:26 AM
I'd say have two versions. Prefer the one without unless the job posting requires a degree.

The way I see it, it's never going to be a positive beyond getting past the resume filter. And I suspect there's a little stigma for criminal justice degrees.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:28 AM
Quote:
Originally Posted by kerowo
I was thinking that too but turns out there is mod bias, mod 5 returns an even remainder for 1 - 7.
yea but I added the values of 5 different rand7 calls. So it's like taking mod 5 of 5-35 so I think the distribution isn't biased.

Last edited by e i pi; 03-18-2015 at 12:42 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:30 AM
I don't know number theory very well, but I suspect that, given a truly random sequence, at least one would have to have an infinite string of 7s.

After thinking on it a bit more, I don't think there is a closed solution to this problem if we are dealing with prime integers. Eh, I misinterpreted the initial problem.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:33 AM
Code:
def rand5():
    return sum([random.randint(1,7) for x in range(1,5)]) % 5 + 1


d = {}
for i in range(10001):
    a = rand5()
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

print(d)
Code:
>>> {1: 1999, 2: 2006, 3: 1969, 4: 2020, 5: 2007}
>>> {1: 1990, 2: 2046, 3: 1986, 4: 1996, 5: 1983}
>>> {1: 1985, 2: 2054, 3: 1996, 4: 2028, 5: 1938}
>>> {1: 2004, 2: 1988, 3: 2067, 4: 1987, 5: 1955}
>>> {1: 1916, 2: 2050, 3: 2052, 4: 1978, 5: 2005}
>>> {1: 2063, 2: 2020, 3: 1957, 4: 1950, 5: 2011}
>>> {1: 2030, 2: 1978, 3: 2027, 4: 1998, 5: 1968}
>>> {1: 2022, 2: 2041, 3: 1987, 4: 2010, 5: 1941}
>>> {1: 1995, 2: 2028, 3: 1973, 4: 2027, 5: 1978}
>>> {1: 1963, 2: 1983, 3: 1979, 4: 2032, 5: 2044}
>>> {1: 1989, 2: 1993, 3: 2009, 4: 1969, 5: 2041}
or 1000000 trials:

Code:
>>> {1: 200388, 2: 201539, 3: 200478, 4: 198936, 5: 198660}
>>> {1: 200440, 2: 201216, 3: 199791, 4: 199375, 5: 199179}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
03-18-2015 , 12:51 AM
It takes more programming skills to verify solutions than to find them for these types of problems.

2000th post
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m