Skip to content

Instantly share code, notes, and snippets.

@withs
withs / palindrome.py
Last active June 5, 2021 09:48
Simple script wich try all 4x4 mumbers and get the highest palindrome of it in Python
"""
Simple script wich try all 4x4 mumbers and get the highest palindrome of it.
Results
-------
- 4x4 numbers (Imac 2013, i5, Python 3.9.2)
Highest palindrome -> 98344389
Found in -> 94.88048125600001 seconds
@withs
withs / palindrome.swift
Last active June 5, 2021 09:45
Simple script wich try all 4x4 mumbers and get the highest palindrome of it in Swift
/*
Simple script wich try all 4x4 mumbers and get the highest palindrome of it.
- results: 4x4 numbers (Imac 2013, i5, swift 5.3.2)
Highest palindrome -> 99000099
Found in -> 240.52266907691956 seconds
- results: 4x4 numbers (Macbook air 2020, M1, swift 5.4)
Highest palindrome -> 99000099
@withs
withs / o_crosshair_indicators.lua
Last active May 10, 2021 10:43
crosshair indicators for Gamesense.pub
-- Shiba (8173)
local surface = require 'gamesense/surface'
local anti_aim = require 'gamesense/antiaim_funcs'
local screen_size = client.screen_size
local entity_get_prop = entity.get_prop
local entity_get_local_player = entity.get_local_player
local ui_get = ui.get
local ui_set = ui.set
local new_hotkey = ui.new_hotkey
@withs
withs / conway.swift
Last active May 14, 2021 15:15
Simple script wich make the suite of conway
/*
Simple script wich make the suite of conway with a give limit (100 on this file)
with some info about the time :)
made on ipad pro in swift playground ^^
*/
import Foundation
let startTime = Date().timeIntervalSinceReferenceDate
@withs
withs / diceware_gen.swift
Last active June 5, 2021 09:40
Two functions wich generate dice combinations for diceware list
/*
Two functions wich generate dice combinations for diceware list, the firstone is oriented to be compact and the seconds oriented to be efficient
- results: withMaxInt: 6 and andMinLenght: 5 (Imac 2013, i5, swift 5.3.2)
Efficient done in -> 62.49544095993042 seconds
Compact done in -> 76.10342800617218 seconds
- results: withMaxInt: 6 and andMinLenght: 5 (Macbook air 2020, M1, swift 5.4)
Efficient done in -> 0.06685197353363037 seconds
Compact done in -> 0.23580491542816162 seconds
@withs
withs / find.cc
Created August 8, 2021 10:05
FInd in string in C String
#include "iostream"
int find(const char* word, const char* in, const int startAt = 0, int endAt = 0) {
int begin;
int verifyCount = 0;
int withSize = std::strlen(in);
// loop jusqu'a trouver une égalité du premier characthere de word et le char de l'index dans la loop
for ( int i = startAt; i <= ((endAt == 0) ? withSize:endAt); i++ ) {
// si le premier char de word et le char de l'index dans la loop sont égaux alors ont enrefistre l'index
// qui correspond a la position du premier char de word
#include "cstdint"
uint16_t intLen(uint32_t forInt) {
uint64_t factor = 1;
uint16_t intLen;
for ( intLen = 0 ; (forInt / factor) != 0 ; intLen++ ) {
factor *= 10;
}
@withs
withs / palindrome.cc
Created October 15, 2021 18:33
palindrome.cc
#include "iostream"
#include "cstdint"
#include "chrono"
// Mac M1 (Apple clang version 13.0.0) 2.9s
// - Highest palindrome -> 98344389
// Ryzen 5 3600x (MinGW-W64 8.1.0) 1.6s
// - Highest palindrome -> 98344389
uint16_t intLen(uint64_t forInt) {
@withs
withs / vectorEnumerate.cc
Last active November 20, 2021 20:32
poc of a simple implementation of python list Enumerate in c++ (c++ vector enumerate)
#include "vector"
#include "cstdint"
// poc of a simple implementation of python list Enumerate in c++
// I choosed to use struct over std::tuple like in (python) because of the way to get the data, i prefer use name over numbers:
// elem.pos > std::get<0>(elem)
template<class T>
@withs
withs / ClosestToPoint2D.cc
Created November 22, 2021 18:34
Get the closest point to a desired coordinate in a 2D space
#include "iostream"
#include "vector"
#include <math.h>
struct Vec3 {
float x,y,z;
};
template <class T>
Vec3 getClosest(std::vector<T> withPosVec, const Vec3 toPos) noexcept {