[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Google Code Jam 2016
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 205
Thread images: 16
File: codejam.jpg (43 KB, 1280x720) Image search: [Google]
codejam.jpg
43 KB, 1280x720
Less than 2 hours to go.
Are you ready /g/?
>>
>>53939151
kill yourself
>>
>>53939151
NEEDS A CODE OF CONDUCT
>>
>>53939177
Can you tell me why?
>>
BUMP
15 minutes!!
>>
>>53939151
at which level can you start to get cash / prizes?
>>
>>53940410

You probably won't need to worry about that
>>
File: 1451279722408.jpg (27 KB, 489x499) Image search: [Google]
1451279722408.jpg
27 KB, 489x499
>mfw I'm making the contest programming in Excel
>>
>>53940441
I know a couple people that got paid to write VBA scripts for excel
>>
>>53940410
You can get a job at Google every round if you're really good.
>>
>>53940459
at big companies you often only have MS office and need to automate annoying tasks, excel VBA script knowledge are pretty neat in those situations and highly valued by your colleagues. Source: I worked at GoldmanSachs
>>
>>53939151
Nice opportunity to show your nice and dandy FizzBuzz, /g/ !
>>
File: 1394241036255.jpg (10 KB, 200x189) Image search: [Google]
1394241036255.jpg
10 KB, 200x189
>it's starting
>>
It's out, get on it you buncha autists
>>
I'm not actually taking part of this just yet, I understand that you can register for the entire duration of the qualifying round
What are the problems like, is this some project euler shit?
>>
>pancakes are back from last year

Oh dear.
>>
>>53940553
This. Board of frauds.A fraud board if you will.
>>
>>53940410
I never get any prizes yet but I got contacted by google recruiter earlier this year, they said they admired my code jam performance. Currently still in interview process though.
>>
>>53940737
They're in revenge now!
>>
>>53939151
im fucking retarded, its been a while since ive done math problems
>>
>>53940737
>>53941034
>not solving the pancake problem by backtracking
step it up you nullptrs
>>
>>53939151
FUCK GOO GOO!
>>
Just finished the first problem. Working on the second :)
>>
>>53941649
>super easy problem
>he needs backtracking at all
Look at this faggot
>>
>>53939177
kys senpai
>>
how the fuck do you do the pancake shit?
>>
>>53942174
>shitposting all day everyday lowered my IQ considerably! Pls help!
I understand but just get your brain to work. The first two problems are super easy.
>>
HOW THE FUCK WHAT WITH THIS PANCAKE AGAIN!!!
>>
well I finished all of them except 4 Large input, which is basically a totally different problem then 4 small... will retry tomorrow but it's 4AM now
>>
>>53939151
Can someone give hints on pancakes please?
>>
>>53943119
litterally reverse engineer the example and notice that it's just dependent on the number of +/- transitions only
>>
>>53942174
you can use a bread first search over all possible configurations of a string, but to do it faster notice that -----+++--++--- is equivalent to -+-+-
>>
>>53943102
You submitted the problem D small? From what I see the small one is super easy while the large is totally in a different level. I'm thinking it would be wise to try doing the large instead and use the small submissions to check whether your large algorithm is correct. You can't do this if you do the small one alone as you can't resubmit if you got it correct.
>>
>>53943119
>>53943126
to expand on that:
* the only way to be able to do it in 0 steps is if it's full +
* the only way to be able to do it in 1 step is if it's - in a row then + in a row
* the only setups were the best is 2 steps are the combinations that places you exactly 1 operation before the previous setups. from all the possible setups that would end in the previous setup by a flip, the only new setup is +-+
etc
>>
>>53943194
well you can re-create the "small" test cases by hand because it's always K = S anyway
>>
>>53943233
Yes you can, what I am saying is that you would be missing the judge feature to check your large algorithms.
>>
What is this even?
>>
>>53943364
Just google that title nerd.
>>
>>53943126
>>53943161
>>53943213
Holy shit I just realized I misunderstood the problem but somehow I passed the small. I'm pretty sure it would pass the large as well. My misunderstanding considerably simplifies the problem so I got nothing to complain.
>>
>>53939151
I don't know why, but I used bash (with friends: factor, sort, uniq) to do C. And I've again been reminded that string handling in bash is shit.
>>
>>53943450
And on that note, factor is a fucking beast of a program. I did not expect it to handle 30-40 digit numbers.
>>
It's that time of the year again. The time to feel dumb. A guy finishes the whole thing in 40 minutes. 2 hours in and I rage quit after solving just 2 problems.
>>
Do you need to generate list of primes for problem C? Generating primes up to 2^32 doesn't seem elegant.
>>
>>53943744
No. You don't want to find primes, you want to find composite numbers. Be lazy, there are a lot more valid coins than you would ever need. Just trying to validate random numbers (starting and ending with 1) works well.
>>
>>53943744

You just need to determine primality.

It's a pity. It just takes way too long for me to write code for the problems, but I can describe the approach well. Not sure if that means I'm not fit to program in some way.
>>
>>53943692

shit happens man, i spent way to long trying to figure out A but i didnt understand what they wanted for the answer, turns out i was just over complicating it.
>>
>>53943744
>>53943773
You might want to sieve some primes (up to 100k is way more than enough) to facilitate factor searching, but that's about it. You don't even need to do any neat primality checks to do this one.
>>
>>53943810
Don't even need to bother sieving, I used just 3, 5, and 7 and got more than enough coins.
>>
I frankly hate this kind of problems. You've an object c which has a list l of items q, s and d for the store t... Fuck that shit. At least real life uses cases makes sense.
>>
File: 1411433887720.png (269 KB, 519x373) Image search: [Google]
1411433887720.png
269 KB, 519x373
>>53944012
same

give me shit like:
Using this shitty software no one knows the code for, find a way to export out 5 million accounts where 1 random broken field on an account will cause the entire system to crash and end the export

Hard mode:
its due in two hours
>>
>>53944096
That's insanely clear. If you know how to do it or you don't, that's up to you, but at least the problem is clear and goes to the point. Zero t, y and f pixies with r and w nuttelas eating p flowers for n cases in i rainbows.
>>
>>53941649
Not posting how I solved but it was so goddamn simple when you figured out what to do.
>>
>>53944380
One of the most natural O(n) solution I've ever seen.
>>
>>53943119
Is it overkill to solve it by A*?
>>
>>53944600
Yes.
>>
File: 1427953540302.png (299 KB, 800x800) Image search: [Google]
1427953540302.png
299 KB, 800x800
So /g/ when did you realize you weren't cut out for programming?
>>
>>53944801
Probably when all my long inputs will come back wrong :(
>>
top
+
-
+
+

Flipping starting at the - gives the same stack.
Do I just move on? Or do I move on and come back?
>>
>>53944600
Why would you- Yes
>>
>>53944961
You need to realize that this:
---+---+
is equivalent to this:
-+-+
so every string can be condensed into a "basic" string of alternating - and +. If you have such a string, how many steps does it take to make them all +?
>>
File: sweaty.jpg (15 KB, 300x300) Image search: [Google]
sweaty.jpg
15 KB, 300x300
>>53945065
>>
>>53945065
shhh, don't tell pajeet the secrets.
>>
Tips for coin jam?
>>
>>53945245
coin on and slam
>>
>>53943773
>>53943789
>>53943810
>>53943928
I am doing large now but my factor searching is running very slowly, it has been 15 minutes but it only managed to finish 30 numbers. Any tips?
>>
>>53945533
Nevermind, I found a way.
>>
Is there any incentive to doing anything beyond the bare minimum required to move on to the next level?
>>
>>53945621
No. Just regard it as a practice I guess. Also, reminder that your large isn't confirmed to be correct yet.
>>
File: angry-eyez.gif (766 KB, 499x235) Image search: [Google]
angry-eyez.gif
766 KB, 499x235
>>53939151
>Counting Sheep
>>
>>53946085
>too stupid to answer the easiest problem

kill yourself, or just quit programming
>>
File: square-1.gif (85 KB, 500x494) Image search: [Google]
square-1.gif
85 KB, 500x494
>>53946326
I did the practice problems available for months before this code jam. No problem.

Oh wait, hurr. I miss it -- the first integer is the number of test cases to follow. Now it makes sense.
>>
File: 1393018895799.jpg (22 KB, 309x346) Image search: [Google]
1393018895799.jpg
22 KB, 309x346
>>53946085
>>53946326
>>53946439
I litterally have no idea how to do counting sheeps
I first tried to multiply the input by K, up to to K= 10 and gather all digits

But for n = 2, you need to go up to 2*45 = 90 to get the digit 9, so mutiplying up to 10 isn't enough

How do you do it?
>>
>>53946519

    while(req != done):
x = x + 1
done = done.union(splitter(x*in))


return x*in
>>
>>53946549
This is O(n^2). You can do it in O(n), though. I think the "large" dataset is not large enough; it should prevent slow algorithm like this.
>>
File: D large.png (4 KB, 194x112) Image search: [Google]
D large.png
4 KB, 194x112
For D Large, I think you can always do it in K-1 at best for complexity C > 1
do you agree?
basically you K = 3 and C = 2 you can do it in 2 using the red marks in pic related. Then for C' > C you just need to find a spot where each of these 2 red marks end up, but it's still 2 spots
>>
>>53946566
Give it a break it's the first problem in the qualification round.
>>
>>53946549
so what's "req"?
>>
>>53946566
What's your n here anyway? I'm pretty sure it doesn't grow as the input number grow, heck I'd say that it's O(1).
>>
what does "submitted " for large problems mean?
if it's green does it mean it's checked and passed the test ? because you get the points
>>
how do I know if I have the optimal number of pancake flips. they dont give you right answers
>>
>>53946831
The large inputs are checked after the round. If you got it right, you get to keep the points. If it's wrong, then you only get the points from the small input. You can only be sure of the small inputs for now.
>>
>>53946983
Just roll your own inductive proof.
>>
FUCKING PANCAKES!!
>>
>>53945065
And what's the difference between +-+ and -+- ?
>>
>>53949722
One takes 1 more flip
>>
>>53945065
>>53949861
I have all the strings in that "basic" form. How can I get the number of steps now?
Some help, please?
>>
>>53949992
Hint: Whatever you do to the top of the stack doesn't affect the bottom. Changing the bottom changes the whole stack. With that in mind, which pancake do you think you should start with?
>>
And done. I'm dubious about D-large, but I think I got the rest.
>>
>>53950286
Yeah, I fucked up D-large. I just realized a better (probably the correct) bound for this task.
>>
I give up
>>
>>53946326
>tfw it took me 40 minutes
I'm rethinking my life right now
>>
>>53950552
How is D-large so much different? As long as your scholars are in an optimal position you should be good.
>>
>>53950732
Took 30 minutes as I overthought it for the first 20. I was going back to my number theory days and trying to find a solution with way too many modulos.
>>
>>53950760
Just treat them as string (chars) and count the string. See >>53946549
>>
>>53950732
took me 10 minutes m8

Only print INSOMNIA for 0 due to number theory (every other number will eventually include 10 digits), then divide by 10 to fill a digits array, escaping when the whole array is filled
>>
Hi senpaitachi I did q 1-3 no problem but I can't figure out q4. Any tips guys?
>>
What's te optimal solution in this pancakes case?
+-+-
>>
I got bored of it. Posting solutions of A and B:
A:
[code#include <stdio.h>
#include <stdint.h>

#define LIMIT 1000

unsigned short get_digits(uint32_t num){
uint16_t digits = 0;
do{
digits |= 1 << (num % 10);
num /= 10;
}while(num > 0);
return digits;
}

uint32_t highest_num(uint32_t num){
uint32_t i = 0;
uint16_t seen_digits = 0;
for(i=1; i<LIMIT; i++){
seen_digits |= get_digits(i * num);
if(0x3ff == seen_digits){
return i * num;
}
}
return 0;
}

int main(int argc, char** argv){
uint32_t n_cases = 0;
uint32_t i = 0;
scanf("%d", &n_cases);
for(i=0; i<n_cases; i++){
uint32_t num = 0;
uint32_t result = 0;
scanf("%d", &num);
result = highest_num(num);
if(0 == result){
printf("Case #%d: INSOMNIA\n", i+1);
}else{
printf("Case #%d: %d\n", i+1, result);
}
}
}[/code]


B:
#include <stdio.h>
#include <string.h>
#include <stdint.h>

uint32_t find_turns(char* str){
uint32_t len = strlen(str);
uint32_t i;
uint32_t turns = 0;
for(i=0; i<(len-1); i++){
turns += str[i] != str[i+1];
}
if(str[len-1] == '-'){
turns++;
}
return turns;
}

int main(int argc, char** argv){
uint32_t n_cases = 0;
uint32_t i = 0;
scanf("%d", &n_cases);
for(i=0; i<n_cases; i++){
char str[101];
scanf("%s", &str);
printf("Case #%d: %d\n", i+1, find_turns(str));
}
return 0;
}
>>
>>53950913
How to do q3 fast? My code works but it's only fast enough for small input cases. I add 2 to every guess each time
>>
>>53950910
4
>>
Algorithm for q2:

1) If first pancake is -, flip the subsequence from first till the last possible pancake with -
2) else find the subsequence with the longest subsequence of pluses and flip it

Repeat 1&2 until solved. Your welcome
>>
>>53950973
Sorry for 2) it's longest subsequence of pluses AT THE END
>>
File: ss (2016-04-09 at 11.48.12).png (12 KB, 184x506) Image search: [Google]
ss (2016-04-09 at 11.48.12).png
12 KB, 184x506
See you at round 1, /g/.
>>
Took me 3 and a half hours for problem D. Goddammit.
>>
I don't get the sample output in A. The testcases are the number of iterations you do?
>>
>>53951501
The output is iterations * n
>>
Any hint for C and D?
>>
>>53952704
C >>53943773
D small is trivial. For large try doing it by hand for smaller input and find the pattern. Totally not trivial.
>>
>>53952904
I can't see that trivial solution for D :( Could you give me a hint?
>>
>>53953161
Again, try doing it by hand first. Also I don't recommend you to do D small first unless you absolutely have no intention to do large. Try solving large and use the judge for small to test your large solution.
>>
>>53953161
Write a sequence such as LLL down on paper, with something like K=3 and C=3 and see what changes in the result if you change different letters in the original to G. You should see a pattern there.
>>
Surprise no one bothered to make a few "You should be able to solve this" edits based on this
>>
>>53953336
I always recommend starting any code algorithm on paper. Has stopped me from deleting hundreds of lines of unneeded code as I already have an algorithm.
>>
D small really was as trivial as it seemed, noice.

Not gonna bother with C large and D large. The C sure caught me off-guard.
>>
>>53955124

C is easy as fuck you ultra pleb, shouldn't be any different than C small if you know what you're doing
>>
File: 1416529818880.jpg (99 KB, 874x924) Image search: [Google]
1416529818880.jpg
99 KB, 874x924
is D large that complicated?
it seems like you can always do it for complexity C=2 with K-1 scholars : >>53946573
and for C > 2 you can do it with the same number of scholars
>>
>>53955124
What was so different about C large? It was as simple as small.
D large you just have to allocate scholars efficently instead of just placing one every K^(C-1)
>>
>>53955152
I did it with K/C scholars.
>>
>>53939151
>google quality
Literally had to unpack android studio again because it started giving me nullpointer error when I tried to do anything. It's garbage. Android is garbage. Google is garbage.
>>
>>53955124
C large is easy when you realize that if you can't tell if a number is prime or not within K iterations, you can just skip it
>>
c small someone.. pls. cant think anymore
>>
>You will have 4 minutes to submit your answer for A-small.
Does it mean that after 4mins it's failed? Where do I find the method interface or however their code calls mine. The instructions aren't very clear.
>>
>>53955546
It literally says it in the spec.
It's a file, formatted as described.

>>53955531
I'm lmaoing at ur lyfe
>>
>>53955531
literally the easiest problem
>>
not a pro dear. wrote code after ages
>>
I'M DOING IT

LET'S HOPE HE'S OFFLINE
>>
GOT CAUGHT ALREADY, DAMMIT I SUCK

WHY WAS I WORRIED ANYWAY
>>
>>53955643
What did you do?
>>
>your output should start with case #1
>first line case #0
fuck this shit
>>
File: coin.png (11 KB, 440x156) Image search: [Google]
coin.png
11 KB, 440x156
>tfw can't coin slam like the best
>have to jam like the rest

I have code that outputs pic
with more lines obviously (J=50)
but its wrong
fug
>>
So if the round ends and I don't have enough points, I'm out?
>>
I literally don't understand the last problem, already done all the others, I don't understand what I'm supposed to do even after reading it twice, what the fuck
>>
>>53957393
is it still on?
>>
>>53957621
Like an hour and a half left I think
>>
>>53956513
Precisely
>>
>>53957621
>>53957631
A little bit more than two hours left.
>>
>>53957393
Not entirely sure either. I'm gonna masturbate first. I'm gonna generate every combination then see if I can draw a pattern from there.
>>
>>53957657
Well it depends entirely on my longs then.
>>
>>53958177
embarassing
>>
>>53958334
guess I am too stoopid for this
>>
>>53957393
I spent 30 minutes just to understand the problem (not solving, just understanding it)

I read this:
>replace each G tile in the complexity X artwork with K G tiles

As:
>replace each G tile in the complexity X artwork with "K * G" tiles

And I was all confused with the examples.
>>
Do you think it would be too late to start this? I forgot it was even happening.
>>
>>53958719
If you're aiming for a perfect, I suppose so. If you're aiming for the 30 points, I guess there's enough time (1 hour and 15 minutes right now).
>>
fucking D large
>>
I don't think I'm getting in. Maybe it wasn't a good idea to start with an hour to go writing my solutions in C.
>>
What's the fucking minimum to get in? I can't find where it says it.
>>
>>53959336
its at the top of the scoreboard page
>>
Any tips on D?
>>
>>53958468
It has an very efficient solution, where you can ignore the tiles completely.
>>
>>53959412
Don't try to simulate it. Really.
There's a recursive function that defines the leftmost solutions.
>>
>>53940492
i have some customers who do their timekeeping in excel macros

of course when they switched from mac to windows i had to go in and reverse all the \ to / in the file paths for them. useless fucking boomers.
>>
Well I would have loved to do this but fuck me I didn't know it was even happening and an hour is too little for me to get 30.

>9 minutes left and only debugging the first solution

Guess there's next year.
>>
Fuck, I just realized the solution to D small and there are only 10 seconds left.

Hug me tight, /codejam/
>>
>>53959896
Same, Wasn't one of the ways to check was the index of k-1?
>>
FUCK
I JUST FINISHED D LARGE
TOO LATE
FUCK
ALL
OF
IT
ONLY 75 Pts LIKE A TRUE CASUAL
>>
File: eh.png (19 KB, 181x484) Image search: [Google]
eh.png
19 KB, 181x484
>>53939151
Onwards
>>
>>53959896
>>53959916
For small, K=S so by just simply checking the first K tiles would do it.
>>
Ranked in 100 - 200 with full 100 points :)
>>
>>53959772
Same anon, feel like a scrub.
>>
>Look at scoreboard
>poo flags
>>
>>53959916
The contest analysis section is open, you can check out the solutions.
>>
75 points, D large wrong. Editorial when?
>>
wow, people really needed to cheat on these problems?

If you can't do these you are going to have problems solving the easiest problem in Round 1, much less 2. So what is the point of getting help?
>>
>>53960155
Basically this.
>>
>>53960010
The contest analysis is there, right on the tab below.
>>
>>53960155
What are you trying to say autist? It's just as you say they wouldn't be able to beat you in later rounds so why are you complaining at all? I wouldn't call it cheating, they aren't copying other's solutions mindlessly and taking people's slots to the next round. They are just learning to solve problems while getting some hints. Are you asking what's the point of learning now?
>>
>>53960280
Yes, realized it from the post just above my post. Thanks anyway.
>>
why don't people do his in functional languages, seems easier than c
>>
What are the best pages/resources to practice for problems? I'm not new to programming contests but I'm not comfortable enough with most of the advanced stuff either. Is Codeforces good?
>>
>>53960280
>>53960010

It is normally up in < 5 minutes after the end. It doesn't always show up until you refresh the page though. Hell, my dash never even showed that someone asked a question and got an answer this time around.

>>53960321
>7. Disqualification.
7.1 You may be disqualified from the Contest and forfeit any prizes you may be eligible to receive if Google reasonably believes that you have attempted to undermine the legitimate operation of the Contest, including:
>(D) Sharing or using from others any information about a problem (including its content or solution) before the end of a round unless expressly permitted by the Contest Rules or these Terms;

It totally isn't cheating. It is only explicitly against the rules! Are you really that maladjusted that you do not understand the basics of friendly competition?
>>
>>53960410
>7.1 Qualification Round. You will not be disqualified in the qualification round of Code Jam for using or sharing information about problems.
>literally one line below
You're fucking retarded.
>>
>>53960410

>Collaborating with anyone else during any round of the contest, with the exception of the qualification round, is strictly prohibited and will result in your disqualification.
>with the exception of the qualification round

Get Fucked, read the FAQs
>>
If you aren't sharing code how would they even tell.
>>
https://strawpoll.me/7330785

Get in here you autists
>>
>>53960410
Even if you can't even read those lines below it isn't that hard to figure out. The qualification round is fucking 27 hours long, google isn't that stupid to expect that nobody would talk about the problems even if they are prohibited to.
Of course I understand the "basics of friendly competition" you are talking about and it will apply starting from the next round. This qualification round is nothing like a competition at all.
>>
>>53960457
>>53960462

I actually missed that because it is several pages down, not "literally one line". I didn't check the FAQ since I've been doing the contest for years.

>>53960647
They only recently starting allowing it apparently (since 2014). If it were incredibly obvious that it would be allowed why did they go for years without allowing it?
>>
File: C.png (72 KB, 600x800) Image search: [Google]
C.png
72 KB, 600x800
Does anyone like bash hacks?
>>
>>53961183
no this is ugly
>>
>>53961183
Unreadable at best.
>>
>>53961264
I'm aware, but it works. Most of the code is getting stupid details out of commands and working with bash's retarded string manipulation. Bash is not a nice looking language, and trying to glue together pieces that really doesn't fit doesn't help.

>>53961308
If you're comfortable with bash and with some of the helpful programs available it's not that bad to get the general idea. Some parts is retarded though, like working around the fact that factor can't return the number of factors of a number.
>>
So, what is this shit about? I kinda started doing is because of this thread but I don't relly know what was going on
Is this just a minor coding competition hosted by google? Why so many few people are participating? Are we even competing for something?
>>
>>53961464
Code jam is a popular contest. This was the qualification round. I think most people do it just for fun, but you'll probably get some perks and opportunities if you get far enough.
>>
>>53961464
27,000 entered this year. Prize is 15k and you get mugged in new york for free.
>>
Google's Code Jam page have 40K likes on Facebook while Facebook's Hacker Cup has 900K. WTF... Are the prizes there better or is it just hundreds of thousands of people thinking that "Hacker Cup" is something about actually hacking facebook accounts?
>>
>>53961629
Probably, but Facebook knows how to bloat number of likes. Illegitimately.
>>
I finally thought of a way to solve for D Large and now I feel like an idiot

welp
>>
>>53961744
I rushed a wrong solution because I had a meeting to catch, and I realized S>=K/C while on the way to the meeting. I was not content.
>>
How do I become a smart and cool programmer who can do these in 40 minutes like some of the others did?
>>
>>53963499
smack ur head with something heavy
u may get smarter
>>
>>53960005
Most of them get disqualified for copy-pasta. The belarusians/russians/chinese are going to the finals again.
>>
>>53964437
u mad
>>
Who else /oneliners/ for pancakes
>>
What's the best pancake flip solution? Feel like mine is pretty crummy.
>if previous, current are -+ or +- flip until previous
>if at last element flip all if -
>>
>>53964643
Just count the number of flips instead of actually flipping
>>
Why is there a week in between rounds? (unless you're a jew I guess)
>>
>>53964583
Post it.
>>
>>53965147
Where stack = the input:
reduce(lambda a, n: (a[0] + (a[1] != n), n), reversed(stack), (0, '+'))[0]
>>
>>53965114
Not everyone is a neet and they need a weekend to compete.
>>
>>53964643
>start from the most bottom -, increase count, go up
>everytime the sign change, increase count
Done.
>>
>>53965168
fuck
>>
>>53965168
I love sed. But I hate that it can't even print the length of the pattern space.

tail -n+2 B-large.in |
sed -nr 's/([+-])\1+/\1/g;s/\+*$//g;s/./+1/g;s/^/0/;=;p' |
bc |
sed -r 'N;s/(.*)\n(.*)/Case #\1: \2/'


Without Case formatting it's a bit neater

sed -nr '1n;s/([+-])\1+/\1/g;s/\+*$//g;s/./+1/g;s/^/0/;p' B-large.in | bc
>>
>>53968166
Is this meant to be readable?
>>
>>53969767
No, it's shit. It's just a couple of autists who want their solution to be one line for literally no reason. Stick with your "normal" language.
>>
>>53969767
No. Readability wasn't the point. It's just meant to work, albeit in a stupid/creative way. The one without formatting can be written more cleanly as
sed -nr '1n;s/([+-])\1+/\1/g;s/\+*$//g;p' B-large.in | awk '{print length}'

which is readable if you know regex and some sed.

1n;               # Skip first line
s/([+-])\1+/\1/g; # Replace repeated - or + with a single - or +
s/\+*$//g;p' # Remove trailing pluses

The length of the resulting string is the number of flips required.
>>
>>53971249
And that p prints the string to stdout, missed that one.
Thread replies: 205
Thread images: 16

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.