Anyone competing?

Anyone competing?
Google Code Jam.

Other urls found in this thread:

pastebin.com/dSXDR9fp
pastebin.com/QPdepfUq
pastebin.com/2ZTiLpnW
twitter.com/NSFWRedditImage

yea did problem a+b, was ok

i won't make it past round 1 anyway

I'm a fucking idiot. I'm struggling with letter c.

So does uploading a fucked up answer give you just a time penalty or does it ruin points as well

Time penalty only. Not that it matters in the qualification round though.

I can't get the first one...

seems like my code works though

What do I have to do to get a t-shirt?? ?

holy FUCK I want a tshirt

Top 1000 on Round 2.

a, b, c1, c2. so Sup Forums how smart are you?

>code
>coding
>coder
>code code code code
GOD DAMNIT I HATE THIS WORD SO FUCKING MUCH FUCK YOU GOOGLE JUST SAY PROGRAMMING YOU CUNTS

why are you so angry at coders, comrade?

>tfw to intelligent for c2

JUST

> t. brainlet

feels bad man

>submit input set for pancake problem
>get it correct
>submit large input
>"Error: non ascii characters in output set"
>times out

JUST

>doing it for free

>having a Google account
Dumb goys.

The multiple of goy is goyim you dumb kike

Quiet goy. Give Google all your data.

>tfw 2 hours left on the clock but you're so tired you cant think straight
why the fuck did I start this so late

No point, I'm not a tranny or a woman

No. I already work for Google.

That explains the recent increase in corporate shilling.

Well anyways since it's nearly finished I figured I'd post my solution for the pancake problem. Is there anything inherently wrong with this?

static void Main(string[] args)
{
var S = 1000;
var num_cases = int.Parse(Console.ReadLine());
bool[][] pancake_row = new bool[num_cases][];
int[] utensil_sizes= new int[num_cases];

for (var i = 0; i < num_cases; i++)
{
var line = Console.ReadLine().Split();
pancake_row[i] = new bool[line[0].Length];

//Fill with 'true' on each + pancake
for (var j = 0; j < pancake_row[i].Length; j++)
if (line[0][j] == '+') pancake_row[i][j] = true;

utensil_sizes[i] = int.Parse(line[1]);
}

for (var i = 0; i < num_cases; i++)
{
var num_flips = GetNumFlips(S, pancake_row[i], 0, utensil_sizes[i]);
if (num_flips >= 0)
Console.WriteLine($"Case #{(i + 1)}: {num_flips}");
else
Console.WriteLine($"Case #{(i + 1)}: IMPOSSIBLE");
}
}

public static int GetNumFlips(int limit, bool[] arr, int flips, int utensil_size)
{
if (flips > limit) return -1;

for (var i = 0; i < arr.Length; i++)
{
if (!arr[i])
{
// Get offsets to start flipping from
for (var j = i; j >= 0; j--)
{
if (!((j + utensil_size - 1) >= arr.Length))
{
for (var k = j; k < j + utensil_size; k++)
arr[k] = !arr[k];
break;
}
}
return GetNumFlips(limit, arr, ++flips, utensil_size);
}
}
return flips;
}

Intel shill here, AMD suxx.

>1hr 20mins remaining
Well fuck, guess there's no real point in me even working on this.

Yes the fact that it's in Java

That's not functional programming fucker

Low quality bait user.

How do you do big input for A
I know you can just go through every case for A-small, but A-large is just too big.

tbqh looks ugly. rate mine
#include
#include
#include
using namespace std;

#define HAPPY '+'
#define SAD '-'
#define MAX_TRIES 1000

void flip(string &pancakes, int pos, int panSize)
{
for (int i = pos; i < min(panSize + pos, (signed int) pancakes.length()); i++)
{
pancakes[i] = pancakes[i] == HAPPY
? SAD : HAPPY;
}
}

int simpleSolveStep(string &pancakes, int panSize)
{
// Try flipping one beginning from the left.
for (int i = 0; i < pancakes.length(); i++)
{
if (pancakes[i] == SAD)
return min(i, pancakes.length() - panSize);
}

return -1;
}

int simpleSolve(string pancakes, int panSize)
{
int pos;
int tries = 0;
while ((pos = simpleSolveStep(pancakes, panSize)) != -1)
{
tries++;
flip(pancakes, pos, panSize);

if (tries > MAX_TRIES) break;
}

return tries;
}

void main()
{
int numberOfCases;
cin >> numberOfCases;

for (int i = 1; i > pancakes >> panSize;

tries = simpleSolve(pancakes, panSize);

if (tries > MAX_TRIES)
cout

it doesn't compile.

Oh yeah, forgot to cast length() to signed int when I was editing. Just change line 25 to
return min(i, (int) pancakes.length() - panSize);

I submitted your solution.

It's wrong.

Same, I just gave up after attempting C because even the test input was going to take several hours for 1 number and they were expecting a response in 8 minutes on 100 numbers up to 10^18 in size.

This is why I'm glad I didn't become an autistic CS major, all the challenges are higher level math problems and they're not even fun.

bruh

What did you become then?

Sounds like a memoisation problem.

A faggot

||=== Build: Debug in csa (compiler: GNU GCC Compiler) ===|
D:\fewfagd\csa\main.cpp||In function 'int simpleSolveStep(std::__cxx11::string&, int)':|
D:\fewfagd\csa\main.cpp|23|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
D:\fewfagd\csa\main.cpp|47|error: '::main' must return 'int'|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 2 second(s)) ===|

Damn. This actually looks interesting. Wish I knew about it sooner.

you can still do the problems without entering, they are public

oh....

Well yeah, forgot main has to explicitly return an int in cpp. My compiler didn't yell at me though

But then I can't win the t-shirt so fuck that

I don't see how memoization could help for this.

>write up solution for c-short
>works well
>try short-2
>runtime is approximately two eons because I forgot they were going to give me fuckhuge numbers
I stopped bothering after that. I figured out how to do it fairly efficiently, but the fact that it works without having to explicitly follow their ruleset for determining the next empty cell made me feel like I got tricked.

What problems are they asking?

Sum all the primes under two million.

C is easy
you only have to solve the binary of the number of people
and it can be proved thaat there are only 2 possible size for every level of spaces (power of 2s) between people
So by finding number of people in toilet
and total space
We can find both types of spaces and which space the current person correspond too.

Why the hell have I noticed this just now?

Submitted pancake small and large, is it sufficient for qualification? Did not have time to do anything more.

The max is probably only like
log(N) space

you need 25 points

No, 30

I meant B sorry.

The tidy numbers one

>tfw thought it was 25 and stopped there
>1 minute remaining

>ok done this tidy shit
>6 secs to run and subbmit

Well I got it correct and it took no time to execute

Qualification Round 2017 - You need at least 25 points to advance to the Round 1s. Remember: the scoreboard assumes that you got all Large datasets right until they are judged at the end of the round, so if you're not sure, consider earning some more points just in case!

this was my pancake
public static int tally = 0;
public static int caseNum = 1;

static void Main(string[] args) {
TextWriter tmp = Console.Out;
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
Console.SetOut(sw);
using (StreamReader stdinput = new StreamReader(Console.OpenStandardInput())) {
string line;
while ((line = stdinput.ReadLine()) != null) {
var liner = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var K = Convert.ToInt32(liner.ElementAt(liner.Length-1));
var pancakes = string.Concat(liner.ElementAt(0));
if (!pancakes.Any(char.IsDigit)) {
while (pancakes != "IMPOSSIBLE" && pancakes != "END") {
pancakes = lineup(pancakes, K);
}
Console.WriteLine("Case #{0}: {1}", caseNum, pancakes == "IMPOSSIBLE" ? "IMPOSSIBLE" : tally.ToString());
tally = 0;
caseNum += 1;
}

}
}
sw.Close();
}

static string lineup(string pancakes, int K) {
if (pancakes.Length k == '-').Count() == 0) {
return "END";
}

if (pancakes.Length < K) {
return "IMPOSSIBLE";
}

if (pancakes.ElementAt(0) == '+') {
return pancakes.Substring(1);
}

tally += 1;
return flipup(pancakes.Substring(0, K)) + pancakes.Substring(K);
}

static string flipup(string pancakes) {
return string.Concat(pancakes.Select(k => k == '+' ? '-' : '+').ToList());
}

Perl master race for pancakes
use strict;
use warnings;
my $T = ;
my ($line, $steps, $temp, $K, @S);
for (my $case = 1; $case

The only other that I solved was the tidy numbers. I was too dumb for the rest.

#include
#include
#include

#define LINE_SIZE 30

int main() {
char line[LINE_SIZE];
fgets(line, LINE_SIZE, stdin);
int T = atoi(line);

for (int nCase = 1; nCase = 0; i--)
for (int j = i; j >= 0; j--)
if (line[j] > line[i]) {
line[i] = '9';
if (h == 0)
line[i-1] = (line[i-1])-1;
}

printf("Case #%d: %lli\n", nCase, atoll(line));
}

return 0;
}

but tidy large has int bigger than 32bit

I'm working the number as a string. I'm only converting to a "long long" to display it. Just to get rid of any leading zeroes.

Here are some solutions. I only really did the first 3 problems.

Here's a link to my solution for part A, the Pancakes one. The small data set completes in 0.002 seconds, the large one completes in 0.927 seconds.

pastebin.com/dSXDR9fp

Here's for part B, the tidy numbers one. Originally it took about 0.7 seconds for each number around 18 digits, but when I added a little memoization it reduced the time to compute each answer to about a millisecond. The small dataset completes in 0.003 seconds, and the large in 0.04 seconds.

pastebin.com/QPdepfUq

And for part C, the bathrooms. This one was actually really easy, I got it in 10 lines of code. I first tried an overly complicated solution involving trees, which was slow and horrible. Really all it is is dividing by 2 and checking if you get an odd or even number. The first small data set finished in 0.001 seconds, the second small set in 0.002 seconds, and the large data set takes 0.005 seconds.

pastebin.com/2ZTiLpnW

>Java
bait

It's actually C#

I wasn't told this would be a feels thread

Fuck can I still participate?

Rate my solution to B (C#)

using System;
using System.IO;
using System.Text;

namespace GoogleCodeJam2017.B
{
class TidyNumbers
{
public static long FindTidy(long n)
{
while(IsNotTidy(n) != -1)
{
int i = IsNotTidy(n);
int l = n.ToString("0").Length;
string x = (long.Parse(n.ToString("0").Substring(0, i)) - 1).ToString("0");
string y = ((long)(Math.Pow(10, l - i)) - 1).ToString("0");
n = long.Parse(x + y);
}
return n;
}

public static int IsNotTidy(long n)
{
string s = n.ToString();
for(int i = 0; i < s.Length-1; ++i)
{
if (s[i] > s[i + 1]) return i + 1;
}
return -1;
}

public static void ReadInput()
{
string filePath = @"\B-large-practice.";

int T;
long[] N;

FileStream fileStream = new FileStream(filePath + "in", FileMode.Open);
using (StreamReader reader = new StreamReader(fileStream))
{
T = int.Parse(reader.ReadLine());
N = new long[T];

string[] input = reader.ReadToEnd().Split('\n');

for(int i = 0; i < input.Length-1; ++i)
{
N[i] = long.Parse(input[i]);
}
}

fileStream = new FileStream(filePath + "out", FileMode.Create);
using (StreamWriter writer = new StreamWriter(fileStream))
{
for (int i = 0; i < N.Length; ++i)
{
writer.WriteLine("Case #" + (i + 1) + ": " + FindTidy(N[i]));
}
}

}
}
}

I've noticed in C# you don't need to worry about stream readers. You can just do Console.ReadLines() and execute the program with the file as the args:

program-two.exe < B-large-practice.in > output.txt

Likewise, with console.writeline, if anything goes out to the console (stdout) you can just append it to a file. I never really thought about that but I've been doing it all the time with C and BASH.

I don't understand your tidy numbers solution at all.
How the fuck did you run thru 10^18 numbers in 0.04s?

>How the fuck did you run thru 10^18 numbers in 0.04s?
Not him, but I get an execution time of 0.001s for the large data set with my solution.

#include
#include
#include

#define ASCII_ZERO 0x30
#define ASCII_NINE 0x39

int main(int argc, char **argv) {
FILE *input_f = fopen("data.in", "r");
FILE *output_f = fopen("data.out", "w");
char buf[255];

int t;
fscanf(input_f, "%i\n", &t);

for (int i=0; i0; j--) {
if (num[j] >= num[j-1])
continue;

num[j-1]--;
for (int k=j; k

It's not 10^18
It's just 18
you just have to solve the digits.
18^3 tops

>tfw scrolling through the leaderboards and checking out random pajeets' code

You can do the same thing in Bash with and >>
Piping operators are standard for pretty much all stdin/stdout operations on any language

because pajeets can't spell let alone pronounce something with that many syllables.

Where are the questions listed?

I want to do them but I don't want to enter

I don't run through many numbers at all actually. I just looked at the 3 "types" of tidy numbers that I could find and got them. The 3 types are either it starts out "tidy", the numbers to the left of the rightmost digit can be lowered to make it "tidy", or you subtract enough to make the rightmost number roll over to a 9. So really all my code does is do a little bit of computation for each digit, it doesn't matter that the number itself is something huge.

No, first year in awhile where I haven't participated.

Took on too many client (self-employed) without thinking some things through and working like 80+ hours a week. Money is good but I am stressed to shit. Few more weeks and one project will be done, hopefully.

fuck all that practice payed off. thank you /g

>tfw my shit takes too long
im pajeet, aren't i

>closed
REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

HOW LONG WAS THE REGISTRATION OPEN

>haskell
no

It's not the registration that is closed, it is the qualification round.

But now I can't qualify so I can't compete, right?

>Participating in Google ScriptCaptcha botnet

You're doing it for free too, you guys are worse than Google's Indian department.

Yes, unfortunately.

>too dumb to solve any problem
>try to cover up with some senseless bs
It's a game. Calm down, sperggie. They don't give a shit about your code. There's nothing you can do that Google can't do a thousand times better.

Nice try, just like captcha was 'temporary' on Sup Forums and you had no contact with google at all, right google employee #12031 aka moot?

>doingitforfree.jpg

Even prostitutes have a better nosiness model than freetards.

Does anyone have a solution to D?

I couldn't figure it out because I am dumb.

Rate B solution
#include
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define FORE(x,val,to) for(auto x=(val);x

readability/10

there's no way anyones that fucking stupid to do sleep instead of just add that to cur date if they alreayd know how to do the math & get cur date

absolutely disgusting
import java.io.*;
import java.util.Scanner;

public class Main {

public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(new File("inputFile.txt"));
PrintWriter output= new PrintWriter(new FileWriter("outputFile.txt"));
int t = scanner.nextInt();
int all = t;
while(t-- > 0){
StringBuffer pancakes = new StringBuffer(scanner.next());
int k = scanner.nextInt(), flips = 0;
for(int i = 0; i < pancakes.length()-k+1; i++){
if(pancakes.charAt(i) == '-') {
flipCon(pancakes, i, k);
flips++;
}
}
boolean good = true;
for(int i = 0; i < pancakes.length() && good; i++){
if (pancakes.charAt(i) == '-') good = false;
}
System.out.println(good ? flips : "IMPOSSIBLE");
output.printf("Case #%d: %s\n", (all-t), good ? flips : "IMPOSSIBLE");
}
output.flush();
}

private static void flipCon(StringBuffer pancakes, int i, int k) {
for(int j = i; j < i+k; j++)
pancakes.setCharAt(j, pancakes.charAt(j) == '-' ? '+' : '-');
}
}

>java
opinion discarded

> participate in code jam / gsoc
> get shirts
> never wear them because then they will fade and shit

Feels bad man.
They should send out like 3-5 shirts so I would use them at least.

post your rust solutions