This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |