Jow Forums Interview

Hello user,

Thanks for coming back for round 5 of our interviewing process. Let's go into the whiteboard room.

Write a function which, given a set of characters and a positive integer L, generates all possible passwords from those characters up to a given length L.

Example:

input: characters = {'a', 'b'}, length = 2
output: ['a', 'b', 'aa', 'bb', 'ab', 'ba']


You should be able to do this, user.

Attached: dilbert23n-2-web.jpg (750x461, 31K)

not doing your homework user

How to program? How to learn how to program?

⍒⍤1∘.=⍨⍵

Is there a limit on character set or L length? Because with larger values, it can take a while.

Small values are fine for demonstration, but it should work for something like 50 characters with length 4.

What should happen when you have an input of
[a,b,c,d]
And length is set to 3 ?

'characters'?
code points, graphemes or just ASCII? don't waste my time

abc
bcd
cda
ab
a
bbb
ccd

etc.

from itertools import chain, product

def powerset_product(iterable, length):
s = list(iterable)
return filter(None, chain.from_iterable(product(s, repeat=r) for r in range(length+1)))

print(tuple(powerset_product("ab", 2)))


Result:

(('a',), ('b',), ('a', 'a'), ('a', 'b'), ('b', 'a'), ('b', 'b'))

>Thanks for coming back for round 5 of our interviewing process.
Subtle. Well done. Mirrors life well.

You can't do it yourself, you have to rely on built-ins?

Typical codemonkey

I'm awful at dynamic programming

>wanting the time inefficient solution

here you go boss man

import itertools
import string


def passwords(chars, length):
results = []
for i in range(1, length + 1):
perms = itertools.permutations(chars, i)
for p in perms:
results.append(''.join(p))
return set(results)

x = passwords(string.ascii_letters, 4)
print(x)

Sorry, we're looking for people who understand recursion.

here u r sir

Solution

Nice work Gurpreet! Here's 300k starting

Hire me and I'll outsource this manual labor that you're spending excessive amounts of money on to folks in India. I can oversee them for appropriate compensation, and they will end up costing you less than the five other individuals you need to actually run the day-to-day in this area of your business.

>mfw I didn't have to do anything technical to get my engineering job

Attached: 1505229091897.jpg (680x441, 79K)

>EE job at a major defense company you have definitely heard of
>literally had to look at an RLC circuit and tell them what it did
>literally a band pass filter
>learned that in circuits 101
w e w

Nice lad. I'm working at a company everyone knows. I find these large companies care more about your attitude and personality more than your technical skills b

Yeah, my interview was 3 sets of 45 minutes meet'n'greet the team behavioral things, and one half hour "do you actually have this degree and did you stay awake for at least a couple classes" technical thing.

def generate_passwords(char_set, L):
password_set = set([""])
for i in range(L):
old_password_set = set(password_set)
for c in char_set:
password_set.update(set([p + c for p in old_password_set]))
password_set.update(set([c + p for p in old_password_set]))

return password_set

very good code sirs

Attached: 1511260952271.png (250x269, 79K)

>"hello welkm 2 my code tootoooorrrreeeyuhl where i vill teech you to write good jawah codes"

I think this works, but I feel like my code is always too complicated or verbose.
set get_all_passwords(vector characters, int length) {
vector fixed_length_passwords;
get_fixed_passwords(fixed_length_passwords, characters, length);
set all_passwords;

for (auto set: fixed_length_passwords) {
for (auto pw: set) {
all_passwords.insert(pw);
}
}

return all_passwords;
}

void get_fixed_passwords(vector &flp, vector &chars, int length) {
set current_pws;

if (length > 0) {
get_fixed_passwords(flp, chars, length - 1);

for (char c : chars) {
for (string s : flp.back()) {
current_pws.insert(s + c);
}
}
} else {
current_pws.insert("");
}

flp.push_back(current_pws);
return;
}

>I feel like my code is always too complicated or verbose.

>tfw i have this exact problem during interviews and am told they were looking for

I have a vagina give me the job anyways.


I think this is the most efficient possible solution.

Alternative solutions:

I'm black please gib job
I'm a tranny pls gib job

its ok, the biggest challenge in programming is writing non niggerlicious code

>Aerospace engineer
>Apply to a factory that makes RD33 for MIGs
>Holy shit an idiot who wants to work for us, welcome we're glad to have you please join
>the job is 10000% relentless beurocracy and lityle to no ingeneering.
>busy collecting signatures, negotiating, writing and rewriting business letters all day every day.
>pays 500$ month barely pays for transport, instant noodles and anime figs
>get recommended for a job of storage engineer at an airport.
>Holy shit yoy're qualified as fuck we want you
>glorified storage keepeer giving our parts to requesting technicians
>24h shifts with ~23h free time to shitpost or sleep.
>pays decent living wages
>mfw a good job just basically found me
>mfw I barely do anything and can affor shit like moving from mom and buying a car
>mfw boss encourages me to go for a promotion

I literally dont know what to do with this.
Will probably blow my first paychecks on high end pc and more animu figures.

Attached: 1518065440884.png (450x511, 299K)

>500/month for an AE

please tell me you're not in the US

The only acceptable answer.

It doesn't account for arbitrary length and that's assuming ⍵ is passing the valid character set. NEXT!

I'm in Moscow.

If my job was actual engineering I would probably stick for experience and titanium space magic.

But instead it was just beurocracy and copy pasting standard technical resolutions such as "the defective part X will still work anyway because ....".
Also production oversight like
>we're rufurbishing an engine, found a scratch on one ball in a bearing please come and sign that you visually confirm the scratch so we can throw it away
>an engine blew up on test go there and just stand and watch entire disassembly process

The worst part is that while I was directly involved in titanium space magic and could stick my head in it to look inside i wasnt really engineering shit or getting fruitful work experience. I was a erannd boy in a monstrous post Soviet beurocratic machine mostly working with papers collecting billions of signatures.

>storage engineer

is appending "engineer" onto titles randomly a common thing?

>being engineer in Russia
Welp, time to move to Canada.

Well Im a highly qualified storage keeper with knowledge what the fuck the things are and what parts go where on the plane.
I might consider it but I bet Pajeet is a preferable candidate, im not even diverse or anything

seriously that problem really grinds me gear
wtf op this is difficult

Just claim that you are gay, and hunted by Putin.

>t. brainlet
This is the most basic combinatorics problem possible.

Attached: potentialdemotivator.jpg (617x435, 33K)

here (you) go faggots
function Fact(num)
{
if(num==0 || num==1) return 1;
return num*Fact(num-1);
}

function RandomInRange(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}


function test(charset, length)
{
var
SubSet = new Array(),
i = 0
;
if(length>charset.length)
{
throw "CHARSET length must be bigger than length you faggots"
}
while(SubSet.length rememberBit) & 1)
{
RememberSet.push(charset[rememberBit]);
}
}
SubSet.push(RememberSet.join(""));
}
return SubSet;
}

Attached: Screenshot_425.png (681x451, 75K)

>javascript
I hope you die painfully in a fire

Hello Mr. user,

I'm happy that I could demonstrate my skills in the last four rounds.
I'm looking foreward to the the next 10 rounds and I'm confident I will convince you that I am the right person for the Junior Developer position internship without payment.

For the solution of this taks I'd like you to have a look at my GitHub portfolio where I already presented a couple of solution of the 0/1-KNAPSACK problem in 7 differnt programming langauges whilst using different algorithms and heuristics. I'd like to suggest the Meet-in-the-middle solution written in Erlang, because it makes intersting use of concurrency while being rubust against unusual input. Since you didn't specify the character set of the input I assume it's part of the task that we can't be sure that the chars will use UFT-8 cahrset, let alone ASCII.

The solution I provided in my portfolio does real time checking of over 17 differnt character sets. If inconsistent input is found, we get an immediate problem detection from the process. The supervisor tree will try to isolate all problems and solve the problem nevertheless with the remaining substrings.

Of course the those problems will get logged and (in case of loss of power) stored at a cloud server. (It hardly needs mentioning that I programmed my own cloud server which is fully encrypted in various ways and has 7 mirrors on differnt locations).

After the algorithm finished that user gets a summary of all errors and solutions. The best solutions (if there is more than one) are located in a seperate cvs file for further processing as well as written down in a graph. That graph is a png made with D3.js and is actually just a radix tree of the differnt solutions which should make it easy for the user to find a possible combination if such a requirement should arise.

I'd like to point out that this is simply a draft, and even though I wrote 13 specs as well as my own fuzzer I would not recommend the usage in production yet.

this must be pasta, right?

Actually I wrote this just now..
:^)

You can tell from the typos..

Damn. You used to post these latter in day.

im saving this, thats actually a really fun exserize

wow
just wow

Thanks for your interest in this position. Unfortunately we've reviewed your application and have decided we won't be moving forward with you for this role.

Thanks again for your interest in working with us. We'll be sure to keep you in mind if anything new comes up that's a good fit.

void pwGenerate(vector alph, int length)
{
srand (time(NULL));
vector result;
for(int i = 1; i 0; j--){
target += pow(alph.size(), j);
}
while(result.size() < target){
string tmp = "";
while(tmp.length() < i)
tmp += alph[rand() % alph.size()];
bool f = true;
for(int j = 0; j < result.size(); j++)
if(result.at(j) == tmp){
f = false;
break;
}
result.push_back(tmp);
}
}
for(int i = 0; i < result.size(); i++)
cout

Noone posts APL without explaining every character user

abloo bloo, cry some more

I have to admit that I already expected this, since this is the third time I applied for this postition.
And being completely honest I also have to admit that my solutions still were flawed. I know this comes off as a sutpid excuse, but I was probably too nervous to up with a worthwhile solutions.

I'd really like to thak you for for your time and appologize because eventually it wasn't a good investment.

I will work hard to improve my skillset to I can hopefully get this job, because I'd love to work for your company. If I ever get there I will compensate the company for my previous failures and will work extra nightshifts.


Thanks a lot for taking your time and see you next year!

- t. user

Easy.

function variations(chars,length){
var res = [];
var a = [0];

while(1){
res.push(a.map(function(v){ return chars[v]; }).join(""));

var position = a.length-1;
while(position>=0){
if(a[position]

>needing recursion for this
lol

>var
>var
>var res = [];

>throw "CHARSET length must be bigger than length you faggots"
That's not true. Charset of one character 'a' and length of three should produce 'a','aa','aaa'.

Is there a problem.

Dunno, I got triggered.

Does the word var trigger you? Why?

Guards, take him.

function Fact(num)
{
if(num==0 || num==1) return 1;
return num*Fact(num-1);
}
function RandomInRange(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function test(charset, length)
{
var
SubSet = new Array(),
i = 0,
target = 0
;
target = (length>=charset.length) ? (charset.length+Fact(length)) : (charset.length+Fact(length+1));
while(SubSet.length> rememberBit) & 1)
{
RememberSet.push(charset[rememberBit]);
}
}
SubSet.push(RememberSet.join(""));
}
if(charset.length==2 && length!=2)
SubSet.push(charset[1]+charset[0]);
else if (charset.length==2 )
SubSet.pop(charset[0]+charset[1]);
return SubSet;
}

did i win?

Attached: Screenshot_427.png (679x1047, 36K)

Jesus Christ this hurts

I dunno. I feel it's still unnecessarily long compared to mine and why is there random in it? Is this a meme submission?

you have to go back

Attached: retard.png (1013x1239, 182K)

Well, that was an actual rejection letter I got in my email just a couple days ago. That's why it looks...

so real ;_; because it is.

I think this works
proc aux {chars prev depth length} {
if {$depth == $length} {return}
set res {}
foreach elem $prev {
foreach char $chars {
lappend res [join [list $elem $char] ""]
}
}
return [concat $prev [aux $chars $res [expr {$depth + 1} ] $length]]
}

proc test {chars length} {
return [aux $chars $chars 0 $length]
}

This made me laugh a lot, highly underrated post

Attached: KC IS DOWN.png (292x271, 31K)

Is this a set of characters meaning literally a set, or a set actually meaning a group?

i.e. Are the characters are unique?

Possibly best post of 2018

from itertools import combinations_with_replacement

f = lambda c, L: ["".join(w) for w in reduce(lambda s, x: s+tuple(x), (combinations_with_replacement(c, x) for x in range(1,L+1)), ())]

That's still 6.25 million password combinations. Could still take a while to print depending on the console type.

I'd hire you to write shitposts on Jow Forums fulltime

#include
#include
#include
#include

void genPasswords(const std::string &chars, int length)
{
uint64_t passwordCount = std::pow(chars.size(), length);
for (uint64_t i = 0; i < passwordCount; ++i)
{
uint64_t div = 1;
for (int j = 0; j < length; ++j)
{
std::cout

Oh wait, doesn't generate shorter lengths. Improved.
#include
#include
#include
#include

void genPasswords(const std::string &chars, int length)
{
while (length > 0)
{
uint64_t passwordCount = std::pow(chars.size(), length);
for (uint64_t i = 0; i < passwordCount; ++i)
{
uint64_t div = 1;
for (int j = 0; j < length; ++j)
{
std::cout

Why not escape on a tractor to a real country

import random
from datetime import datetime, timedelta

def combinations(charecters, length):
result = set()
start = datetime.now()
while True:
result.add(u''.join([random.choice(list(charecters)) for _ in range(random.randint(1, length))]))
if datetime.now() > start + timedelta(seconds=10):
return list(result)

> Opens Eclipse
We will start devil-up-ment of spring boot application

>output: ['a', 'b', 'aa', 'bb', 'ab', 'ba']
You missed '' in this reference output. The empty string is a possible password.

Many have tried, but few have succeeded..

no faggot, no.

import itertools
itertools.permutations(characters)

Where's my 500k a year job?

That's wrong, you want permutations with repetition.

#!/usr/bin/env ruby

def pwgen(c, l, s = '')
return s if (l==0)
r = [];
c.each {|i| r

pwList xs = xs ++ [x ++ y | x

>round 5 of our interviewing process
how desperate do you have to be to go to a 5th interview with the same retarded company?

I'm done bro. I'd rather be homeless than keep going through this shit

yes.

e.g. Petroleum Transfer Engineer

Remove the second password_set.update() and this becomes the best solution

def generate_passwords(char_set, L):
password_set = set([""])
for i in range(L):
old_password_set = set(password_set)
for c in char_set:
password_set.update(set([p + c for p in old_password_set]))

return password_set

>mfw brainlets need to import libraries and write 30 lines of code to solve this

Whoops, forgot to include the len

Attached: pwgen.png (145x513, 3K)

#include
#include
#include
std::vector passgen(std::vector charset, size_t length){
std::vector v;
if(!length) return v;
for(auto c : charset)
v.emplace_back(1,c);
while(--length)
for(size_t i=0, j = v.size(); i

>If I ever get there I will compensate the company for my previous failures and will work extra nightshifts.
something something girlfriend's son

>std::vector v;
pre-allocate it pleb:
std::vector v(
( [](size_t b, size_t e){
size_t pow = 1;
while(e){
if(e&1)
pow *= b;
b*=b;
e>>=1;
}
return pow;
}(charset.size(), length+1) - charset.size() ) / (charset.size() - 1)
);

Are you guys memeing?, because I'm starting to feel smart

>std::vector v(

The constructor doesn't reserve. You need to call v.reserve(...)

>using auto
not even once

#include
#include
#include

std::vector passgen(std::vector charset, size_t length){
std::vector v;
if(!length || !charset.size()) return v;
auto geometric_sum = [](size_t base, size_t number){
auto pow = [](size_t b, size_t e){
size_t pow = 1;
while(e){
if(e&1)
pow *= b;
b*=b;
e>>=1;
}
return pow;
};
return (pow(base, number+1) - base) / (base - 1);
};
v.reserve(geometric_sum(charset.size(), length));
for(auto c : charset)
v.emplace_back(1,c);
size_t i=0;
while(--length){
for(size_t j = v.size(); i

What's wrong with auto?