Skip to content

Instantly share code, notes, and snippets.

View jollyjoester's full-sized avatar

Hideyuki Nanashima jollyjoester

View GitHub Profile
@jollyjoester
jollyjoester / tech_slide_memo.md
Created December 24, 2022 03:25
Tech Slide memo
@jollyjoester
jollyjoester / GAKKOU.kt
Created January 28, 2022 07:06
What is the 100th word in the permutation of "GAKKOU"? in Kotlin
fun main() {
val string = "GAKKOU"
val chars: List<Char> = string.toList()
val word = chars.permutations().distinct().map { it.toCharArray().concatToString() }.sorted()[99]
println(word)
}
fun <T> List<T>.permutations(): List<List<T>> {
if (this.isEmpty()) return listOf(emptyList())
@jollyjoester
jollyjoester / GAKKOU.swift
Created January 28, 2022 06:51
What is the 100th word in the permutation of "GAKKOU" in Swift
import Algorithms
let word = ("GAKKOU".permutations().uniqued().map { String($0) }.sorted(by: <)[99])
print(word)
@jollyjoester
jollyjoester / main.go
Last active July 18, 2020 15:58
basic_golang_v2
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
@jollyjoester
jollyjoester / swift-and-legacy of functional-programming.swift
Last active July 14, 2018 03:27
swift-and-legacy of functional-programming.swift
import Foundation
// try! Swift NYC 2016
// https://academy.realm.io/posts/tryswift-rob-napier-swift-legacy-functional-programming/
// Sample1: 分解して再構築
struct Person {
let name: String
let isValid: Bool = true
}
@jollyjoester
jollyjoester / fizzbuzz.swift
Created April 15, 2017 06:50
fizzbuzz in Swift
(1...100).map {
switch ($0 % 3, $0 % 5) {
case (0, 0): return "Fizz Buzz"
case (0, _): return "Fizz"
case (_, 0): return "Buzz"
case (_, _): return "\($0)"
}
}.forEach { print($0) }
@jollyjoester
jollyjoester / fizzbuzz.kt
Last active April 15, 2017 06:47
fizzbuzz in kotlin
(1..100).map {
when {
it % 15 == 0 -> "fizzbuzz"
it % 3 == 0 -> "fizz"
it % 5 == 0 -> "buzz"
else -> it.toString()
}
}.forEach { println(it) }
@jollyjoester
jollyjoester / CodePiece.swift
Created January 28, 2017 06:02
すしを流す #love_swift #CodePiece
import UIKit
import PlaygroundSupport
let view = UIView(frame: CGRect(x: 0, y:0, width:320, height:44))
view.backgroundColor = UIColor.black
PlaygroundPage.current.liveView = view
(0...2).forEach {
let sushi = UILabel(frame: CGRect(x: 320, y: 0, width: 44, height: 44))
@jollyjoester
jollyjoester / sushi.swift
Last active November 28, 2016 04:13
sushi-go-round
import UIKit
import PlaygroundSupport
let view = UIView(frame: CGRect(x: 0, y:0, width:320, height:44))
view.backgroundColor = UIColor.black
PlaygroundPage.current.liveView = view
(0...2).forEach {
let sushi = UILabel(frame: CGRect(x:320, y:0, width:44, height:44))
@jollyjoester
jollyjoester / CodePiece.swift
Created July 18, 2016 08:24
teratailのpython月間タグ別ランキングTop10のユーザー名取ってみた #CodePiece #pynyumon
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import urllib.request
from bs4 import BeautifulSoup
html = urllib.request.urlopen('https://teratail.com/tags/Python')
soup = BeautifulSoup(html, 'lxml')
userRanking_month = soup.find(id='userRanking__month')