Skip to content

Instantly share code, notes, and snippets.

View swawa-yu's full-sized avatar

swawa-yu swawa-yu

View GitHub Profile
open System.Linq
// aabbbcdddd -> [(a,2), (b,3), (c,1), (d,4)]
let runLength (s: string) =
let heads = { 1 .. s.Length - 1 }.Where(fun i -> s.[i - 1] <> s.[i]).Prepend(0).Append(s.Length).ToArray()
{ 0 .. heads.Length - 2 }.Select(fun i -> s.[heads.[i]], heads.[i + 1] - heads.[i]).ToArray()
// 使用例
input()
|> runLength
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
/*RULE
|0 -> nothing | 1 -> wall | 2 -> goal | 3 -> answer|
|0 -> 下 | 1 -> 右 | 2 -> 上 | 3 -> 左|
map