JOIN
Get Time
forums  Revision History
Search My Post History  |  My Watches  |  User Settings
Forums Algorithm Matches SRM 534 Re: Div1 250 short solution Revision History (7 edits)
Re: Div1 250 short solution (response to post by vasja_p)
Okay, venco, you're on: 62(?) characters seems way too many for me.

#include <string>
using namespace std;
class EllysCheckers {
public:
string getWinner(string b) {
int L=b.size(),p=0;
for (; L>1; ) p ^= b[L-=2]; // assume ASCII
return p&1?"YES":"NO";
}
};

[ETA:
- Hah! I didn't know I could use string::size() instead of ::length();
- ASCII comment
- '.' => 46
]
[ETA2:
- replaced >46 with later &1
]
[ETA3:
- moved L declaration to single int
]
[ETA4:
- moved & expanded ASCII/EBCDIC comment
]
[ETA5:
- removed EBCDIC claim; it won't work
]
[ETA6:
- ; => ,
- moved comment back
]
Re: Div1 250 short solution (response to post by vasja_p)
Okay, venco, you're on: 62(?) characters seems way to many for me.

#include <string>
using namespace std;
class EllysCheckers {
public:
string getWinner(string b) {
int L=b.size(),p=0;
for (; L>1; ) p ^= b[L-=2]; // assume ASCII
return p&1?"YES":"NO";
}
};

[ETA:
- Hah! I didn't know I could use string::size() instead of ::length();
- ASCII comment
- '.' => 46
]
[ETA2:
- replaced >46 with later &1
]
[ETA3:
- moved L declaration to single int
]
[ETA4:
- moved & expanded ASCII/EBCDIC comment
]
[ETA5:
- removed EBCDIC claim; it won't work
]
[ETA6:
- ; => ,
- moved comment back
]
Re: Div1 250 short solution (response to post by vasja_p)
Okay, venco, you're on: 62(?) characters seems way to many for me.

#include <string>
using namespace std;
class EllysCheckers {
public:
string getWinner(string b) {
int L=b.size();p=0; // assume ASCII
for (; L>1; ) p ^= b[L-=2];
return p&1?"YES":"NO";
}
};

[ETA:
- Hah! I didn't know I could use string::size() instead of ::length();
- ASCII comment
- '.' => 46
]
[ETA2:
- replaced >46 with later &1
]
[ETA3:
- moved L declaration to single int
]
[ETA4:
- moved & expanded ASCII/EBCDIC comment
]
[ETA5:
- removed EBCDIC claim; it won't work
]
Re: Div1 250 short solution (response to post by vasja_p)
Okay, venco, you're on: 62(?) characters seems way to many for me.

#include <string>
using namespace std;
class EllysCheckers {
public:
string getWinner(string b) {
int L=b.size();p=0; // assume ASCII; use p=1 for EBCDIC
for (; L>1; ) p ^= b[L-=2];
return p&1?"YES":"NO";
}
};

[ETA:
- Hah! I didn't know I could use string::size() instead of ::length();
- ASCII comment
- '.' => 46
]
[ETA2:
- replaced >46 with later &1
]
[ETA3:
- moved L declaration to single int
]
[ETA4:
- moved & expanded ASCII/EBCDIC comment
]
Re: Div1 250 short solution (response to post by vasja_p)
Okay, venco, you're on: 62(?) characters seems way to many for me.

#include <string>
using namespace std;
class EllysCheckers {
public:
string getWinner(string b) {
int L=b.size();p=0;
for (; L>1; ) p ^= b[L-=2]; // assume ASCII
return p&1?"YES":"NO";
}
};

[ETA:
- Hah! I didn't know I could use string::size() instead of ::length();
- ASCII comment
- '.' => 46
]
[ETA2:
- replaced >46 with later &1
]
[ETA3:
- moved L declaration to single int
]
Re: Div1 250 short solution (response to post by vasja_p)
Okay, venco, you're on: 66 characters seems way to many for me.

#include <string>
using namespace std;
class EllysCheckers {
public:
string getWinner(string b) {
int p=0;
for ( int L=b.size(); L>1; ) p ^= b[L-=2]; // assume ASCII
return p&1?"YES":"NO";
}
};

[ETA:
- Hah! I didn't know I could use string::size() instead of ::length();
- ASCII comment
- '.' => 46
]
[ETA2:
- replaced >46 with later &1
]
Re: Div1 250 short solution (response to post by vasja_p)
Okay, venco, you're on: 67 characters seems way to many for me.

#include <string>
using namespace std;
class EllysCheckers {
public:
string getWinner(string b) {
int p=0;
for ( int L=b.size(); L>1; ) p ^= b[L-=2]>46; // assume ASCII
return p?"YES":"NO";
}
};

[ETA:
- Hah! I didn't know I could use string::size() instead of ::length();
- ASCII comment
- '.' => 46
]
Re: Div1 250 short solution (response to post by vasja_p)
Okay, venco, you're on: 70 characters seems way to many for me.

#include <string>
using namespace std;
class EllysCheckers {
public:
string getWinner(string b) {
int p=0;
for ( int L=b.length(); L>1; ) p ^= b[L-=2]>'.';
return p?"YES":"NO";
}
};