Skip to content

Instantly share code, notes, and snippets.

❯ benchstat v3.txt v4_garman_bytes.txt
name old time/op new time/op delta
Answer-8 136ns ± 0% 23ns ± 0% -83.28% (p=0.016 n=4+5)
❯ benchstat v4_fugi.txt v4_garman_bytes.txt
name old time/op new time/op delta
Answer-8 37.8ns ± 0% 22.8ns ± 0% -39.66% (p=0.008 n=5+5)
#include <cstdio>
using namespace std;
int main(int argc, char** argv) {
printf("[");
char* cur = argv[1];
int count = 1;
for (;*cur;++cur, ++count) {
if (cur[0] != cur[1]) {
printf("(\"%c\", %ld)%s", cur[0], count, cur[1] ? " ,": "");
# generated by SuperSlicer 2.3.55 on 2020-12-15 at 07:14:58 UTC
allow_empty_layers = 0
avoid_crossing_not_first_layer = 1
avoid_crossing_perimeters = 0
bed_custom_model =
bed_custom_texture =
bed_shape = 0x0,250x0,250x210,0x210
bed_temperature = 105
before_layer_gcode = ;BEFORE_LAYER_CHANGE\nG92 E0.0\n;[layer_z]\n\n
between_objects_gcode =

Pretty ugly solution, relies on knowledge about the data. Works.

@garethlewin
garethlewin / Notes.MD
Created January 3, 2016 05:06
Solution for year 32 of Human Resource Machine

This is a disgusting solution, but it works. The speed challenge wants you to take up to 393 steps (on average), this takes 81

If you know anyone that wrote code like this for a real problem, don't hire them.

using namespace std;
#include <thread>
#include <iostream>
#include <vector>
#include <algorithm>
#include <windows.h>
#include <conio.h>
enum class TypeOfSleep
{
TTV_ErrorCode ttv::Socket::Recv(uint8_t* buffer, size_t length, size_t& received, bool fillBuffer/*=false*/)
{
auto state = mAsyncOpComplete->SuspendFor (0);
if (TTV_FAILED(state))
{
return state;
}
if ( state == TTV_EC_SUCCESS)
template <class values_t>
class DurationBasedStatsContainer
{
public:
typedef std::list<std::pair<std::chrono::high_resolution_clock::time_point, typename values_t>> valueList_t;
typedef std::chrono::milliseconds freq_t;
DurationBasedStatsContainer(freq_t maxDuration);
void push(values_t&& value);
typedef std::map<std::wstring, std::wstring> tokenMap_t;
inline tokenMap_t GetURLTokens(std::wstring input)
{
tokenMap_t result;
auto tokenStartPos = input.find_first_of(L"?#");
while (tokenStartPos != std::string::npos)
{
tokenStartPos++;
auto tokenEndPos = input.find_first_of(L"=&", tokenStartPos);
inline std::vector<std::pair<std::wstring, std::wstring>> GetURLTokens(std::wstring input)
{
std::vector<std::pair<std::wstring, std::wstring>> result;
auto tokenStartPos = input.find_first_of(L"?#");
while (tokenStartPos != std::string::npos)
{
tokenStartPos++;
auto tokenEndPos = input.find(L"=", tokenStartPos);
if (tokenEndPos != std::string::npos)
{