Skip to content

Instantly share code, notes, and snippets.

View gavrilovmiroslav's full-sized avatar
🎯
Focusing

Miroslav gavrilovmiroslav

🎯
Focusing
View GitHub Profile
// recursion schemes in c++: implement `map`, get `fold` for free!
// author: Maxime Tournier
// date: November 2019
// license: MIT
// TODO:
// - anamorphisms, hylomorphisms & friends
// - handle bi-functors gracefully (not clear whether the usual list functor can
// be implemented together with the one presented here)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace GMPool
{
public class Pool<T> : IEnumerable<T> where T : class, new()
{

You might know some or all of this introduction but here's all of it for pedantic reasons. So, there's this thing called multiplicative persistence, which is basically the count of times a number can be reduced by multiplying its digits together until the result is a single digit number. For example, 89 has an MP of 3 because it takes three steps to reduce it to a single digit number:

89
8*9 = 72
7*2 = 14
1*4 = 4

Now, if you take some time to investigate, it turns out that many numbers fail at having a high MP rather quickly: they devolve because at some point 2 and 5 meet and form a 10, and that zero is a sink. Multiplying with 1 keeps the score, but reduces the number of digits available for the next step; all of this rings to me like either a structure (group maybe) or an extension on the ring of natural numbers, but I'm not sure about it yet. At any rate, the highest MP ever found is 11. It isn't proven that that is the highest possible, but extensive checking suggests it. One such number is 277

@gavrilovmiroslav
gavrilovmiroslav / index.html
Last active June 20, 2019 12:19
Pure HTML templating
<!-- a template defining three nested template calls -->
<template id='three-hellos'>
<!-- first hello is missing a surname -->
<hello-world data-name="Mark"></hello-world>
<hello-world data-name="Sue" data-surname="Sanders"></hello-world>
<hello-world data-name="Derek" data-surname="Dickens"></hello-world>
</template>
<!-- a hello world template that writes a hello message -->
<template id='hello-world'>
@gavrilovmiroslav
gavrilovmiroslav / ascii.scala
Created January 14, 2018 07:57
A java-compliant 8-bit ASCII to Unicode conversion array
object Ascii {
val asciiToUnicode = Array(
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0x0000, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022, 0x25d8, 0x25cb, 0x25d9, 0x2642, 0x2640, 0x266a, 0x266b, 0x263c, // 0
0x25ba, 0x25c4, 0x2195, 0x203c, 0x00b6, 0x00a7, 0x25ac, 0x21a8, 0x2191, 0x2913, 0x2192, 0x2190, 0x221f, 0x2194, 0x25b2, 0x25bc, // 1
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, // 2
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, // 3
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f, // 4
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f, // 5
0x0060, 0x0061, 0x0062, 0x0063, 0
#include <type_traits>
#include <iostream>
struct Base
{
void x()
{
std::cout << "X called from parent! " << std::endl;
}
};
// a -> a' <=> a -> [a]
// a -> 'a <=> for quotes, [a] -> a;
for values, 'a == a
// linear
// #rhs ≤ #lhs
zap :: a ->
i :: a -> 'a
unit :: a -> a'
Hey, Lucas, sorry for bothering you over the weekend, I wanted to pass an idea along, to see whether you think we could maybe use something from it. I'll try to explain it on a simple example function in some weird labelled quasijava:
a: input = INPUT();
if(input > 1000)
b: return CALCULATION();
do {
c: input += 7;
d: RANDOM_LONG_CODE();
} until(input <72);
e: return input;
Based on our records and DHCP here are the VLAB machines
Managed computers are named after musical instruments
piano - server
bass
banjo
drum
guitar
Unmanaged Ubuntu computers are named after carving tools
> run
[info] Compiling 1 Scala source to C:\Users\Pandora\.babun\cygwin\home\Pandora\pkmn\target\scala-2.10\classes...
[warn] there were 1 feature warning(s); re-run with -feature for details
[warn] one warning found
[info] Running Main
Player(
mika,
Prizes(List(squirtle, water, level ball, water, water, level ball)),
Hand(List(keldeo, squirtle, water, water, keldeo, level ball, keldeo)),
Active(None),