Skip to content

Instantly share code, notes, and snippets.

View yokolet's full-sized avatar
🏠
Doing Rails dev now

Yoko Harada yokolet

🏠
Doing Rails dev now
View GitHub Profile
@yokolet
yokolet / kata_transcription.py
Last active May 20, 2019 04:50
katakana transcription
# https://en.wikibooks.org/wiki/Japanese/Transcribing_English_to_Japanese
import os
import sys
sys.path.append(os.path.abspath('./English-to-IPA'))
from pykakasi import kakasi
import romkan
import eng_to_ipa as ipa
import re
@yokolet
yokolet / rss_feeds.xml
Created April 15, 2011 03:07
RSS feed from cnn.com
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?>
<?xml-stylesheet type="text/css" media="screen" href="http://rss.cnn.com/~d/styles/itemcontent.css"?>
<rss version="2.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xmlns:media="http://search.yahoo.com/mrss/"><channel>
<title>CNN.com</title>
<link>http://www.cnn.com/?eref=rss_topstories</link>
<description>CNN.com delivers up-to-the-minute news and information on the latest top stories, weather, entertainment, politics and more.</description>
<language>en-us</language>
<copyright>© 2011 Cable News Network LP, LLLP.</copyright>
<pubDate>Thu, 14 Apr 2011 22:18:26 EDT</pubDate>
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class RestoreLotteryNumber {
static void restoreLotteryNumbers(String s, List<String> result, Set<String> seen,
String number, int count, int index) {
if (count > 7) { return; }
if (count == 7 && number.length() == (s.length() + 6)) {
@yokolet
yokolet / length_of_longest_substring_k_distinct.py
Created October 18, 2018 20:21
Longest Substring with At Most K Distinct Characters
"""
Description:
Given a string, find the length of the longest substring T that contains at most k
distinct characters.
Examples:
Input: s = "eceba", k = 2
Output: 3 -- 'ece' is the longest
Input: s = "aa", k = 1
@yokolet
yokolet / plus_one.py
Created October 18, 2018 19:29
Plus One
"""
Description:
Given a non-empty array of digits representing a non-negative integer, plus one to the
integer. The digits are stored such that the most significant digit is at the head of
the list, and each element in the array contain a single digit. You may assume the
integer does not contain any leading zero, except the number 0 itself.
Examples:
Input: [1,2,3]
Output: [1,2,4]
@yokolet
yokolet / spiral_order.py
Created October 18, 2018 19:11
Spiral Matrix
"""
Description:
Given a matrix of m x n elements (m rows, n columns), return all elements of the
matrix in spiral order.
Examples:
Input:
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
@yokolet
yokolet / alien_order.py
Created October 18, 2018 02:28
Alien Dictionary
"""
Description:
There is a new alien language which uses the latin alphabet. However, the order among
letters are unknown to you. You receive a list of non-empty words from the dictionary,
where words are sorted lexicographically by the rules of this new language. Derive the
order of letters in this language.
- You may assume all letters are in lowercase.
- You may assume that if a is a prefix of b, then a must appear before b in the given dictionary.
- If the order is invalid, return an empty string.
- There may be multiple valid order of letters, return any one of them is fine.