[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Here's my week assignment: you have the number 237612231.

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 30
Thread images: 1

File: aK3ro51_700b_v1.jpg (88KB, 600x600px) Image search: [Google]
aK3ro51_700b_v1.jpg
88KB, 600x600px
Here's my week assignment: you have the number 237612231. Make how many IPs combination you can in any language. IP format #.#.#.# (each # hold up 1 to 3 digits)
>>
Here's what I going to deliver in python
v = '237612231'
print "{}.{}{}.{}{}{}.{}{}{}".format(*v) # 1 2 3 3
print "{}.{}{}{}.{}{}.{}{}{}".format(*v) # 1 3 2 3
print "{}.{}{}{}.{}{}{}.{}{}".format(*v) # 1 3 3 2
print "{}{}.{}.{}{}{}.{}{}{}".format(*v) # 2 1 3 3
print "{}{}.{}{}{}.{}.{}{}{}".format(*v) # 2 3 1 3
print "{}{}.{}{}{}.{}{}{}.{}".format(*v) # 2 3 3 1
print "{}{}.{}{}.{}{}.{}{}{}".format(*v) # 2 2 2 3
print "{}{}.{}{}.{}{}{}.{}{}".format(*v) # 2 2 3 2
print "{}{}.{}{}{}.{}{}.{}{}".format(*v) # 2 3 2 2
print "{}{}{}.{}{}.{}{}{}.{}".format(*v) # 3 2 3 1
print "{}{}{}.{}{}{}.{}{}.{}".format(*v) # 3 3 2 1
print "{}{}{}.{}.{}{}.{}{}{}".format(*v) # 3 1 2 3
print "{}{}{}.{}{}.{}.{}{}{}".format(*v) # 3 2 1 3
print "{}{}{}.{}.{}{}{}.{}{}".format(*v) # 3 1 3 2
print "{}{}{}.{}{}{}.{}.{}{}".format(*v) # 3 3 1 2
print "{}{}{}.{}{}.{}{}.{}{}".format(*v) # 3 2 2 2


I'm feeling very dumb to come up with that arbitrary solution. =(
>>
>>57090583
999.999.999.999 isn't an IP address.
>>
>>57090583
i dont understand the question
you have to make as many ip addresses as you can using those digits right? do they have to be in that order always?
>>
>>57090621
Read the question. You ware given an arbitrary number
>>
>>57090659
Yes, you have to make as many ips combination with that number in that order
>>
>>57090680
well then in that case your solution wont work as it would output some numbers higher than 255
>>
>>57090720
Yes, I'm aware of that
>>
You have to focus on the format of the ip, not in if it's valid
>>
>>57090752
its actually quite easy to fix since the numbers are in a predetermined order

hence all # 13 XX are invalid etc etc
so just delete those lines
>>
>>57090778
code?
>>
You should really be starting with calculating the number of permutations rather than going straight to code.
>>
it was a shitty exercise that was supposed to be done in 1:30 hour. that was my shitty solution.
>>
>>57094020
asking for help? I posted my solution asshole. the question was just to format the given number in the ip formart, not verify if it's a valid ip.
>>
>>57090607
I don't know programming but:

Return every single combination with 3 dots in it
filter out any number that's longer than 3 digits without a dot point to break it
filter out any number above 255

Get a fucking brain, nerd.
>>
>>57090583
>can't even solve this
>being this retarded
>even a pajeet like me can solve this

def solve(s, i, lim):
if i > 3:
return
elif i == 3:
if len(s) == 3:
lim[i] = int(s)
print(lim)
return
for k in range(3):
if k + 1 < len(s):
lim[i] = int(s[:k+1])
solve(s[k+1:], i+1, lim)

if __name__ == "__main__":
s = "237612231"
solve(s, 0, [0, 0, 0, 0])
>>
>>57094478
and if you want each part to be less than 255, just add the condition before printing
>>
>>57094478
and this was the output

[2, 37, 612, 231]
[2, 376, 12, 231]
[23, 7, 612, 231]
[23, 76, 12, 231]
[23, 761, 2, 231]
[237, 6, 12, 231]
[237, 61, 2, 231]


with the condition that no number should be greater than 255

[23, 76, 12, 231]
[237, 6, 12, 231]
[237, 61, 2, 231]
>>
>>57094510
Well, here's my output:
2.37.612.231
2.376.12.231
2.376.122.31
23.7.612.231
23.761.2.231
23.761.223.1
23.76.12.231
23.76.122.31
23.761.22.31
237.61.223.1
237.612.23.1
237.6.12.231
237.61.2.231
237.6.122.31
237.612.2.31
237.61.22.31
>>
>>57094510
23.76.122.31

Dumbass, kill yourself

>>57094712
Get rid of the numbers above 255 and you got it, champ.
>>
>>57094729
I told you not to validate the IP, just make as much combinations IP LIKE as you can
>>
Actual solution

[23, 76, 12, 231]
[23, 76, 122, 31]
[237, 6, 12, 231]
[237, 6, 122, 31]
[237, 61, 2, 231]
[237, 61, 22, 31]
[237, 61, 223, 1]


Code:

def solve(s, i, lim):
if i > 3:
return
elif i == 3:
if len(s) <= 3 and max(lim) <= 255:
lim[i] = int(s)
print(lim)
return
for k in range(3):
if k + 1 < len(s):
lim[i] = int(s[:k+1])
solve(s[k+1:], i+1, lim)

if __name__ == "__main__":
s = "237612231"
solve(s, 0, [0, 0, 0, 0])
>>
>>57094712
well mine isn't hardcoded, idiot
>>
>>57094729
I just forgot to put <= in line 5
>>
>>57094769
well, that's fair.
>>
>>57094802
how long did it took you?
>>
>>57090583
s = '237612231'

for i in range(1,4):
for j in range(1,4):
for k in range(1,4):
for l in range(1,4):
if i+j+k+l == 9:
print ('.'.join([s[0:i],s[i:i+j],s[i+j:i+j+k],s[i+j+k:i+j+k+l]]))
>>
>>57095095
Yes, a had a similar one, but was bugged.
>>
>>57090669
And there are no limits set on how you can use that arbitary number. For example if you times it by 9000 and use the result as the max for a range of numbers to generate IPs from -> all the possible IP's
>>
>>57090607
>
print "{}{}{}.{}{}{}.{}.{}{}".format(*v) # 3 3 1 2

>237.612.2.31
Thread posts: 30
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.